I'm not really familiar with PHP. I've been asked to add a recurring payment option to an already existing website that charges subscriptions to a magazine. Looking at the code I found this section:
$paypal = new Paypal('en');
$paypal->API_UserName = API_USERNAME;
$paypal->API_Password = API_PASSWORD;
$paypal->API_Signature = API_SIGNATURE;
$paypal->API_Endpoint = 'https://api-3t.paypal.com/nvp' ;
$paypal->lang_id = 'en';
$paypal->country_code = 'CA';
$paypal->operation = OPERATION;
$paypal->payment_type = PAYMENT_TYPE;
$paypal->email = $Subscription->email;
$paypal->firstname = $Subscription->first_name;
$paypal->lastname = $Subscription->last_name;
$paypal->address = $Subscription->address;
$paypal->city = $Subscription->city;
$paypal->state = $Subscription->province;
$paypal->zip = $Subscription->postal_code;
$paypal->ship_address = $paypal-> address;
$paypal->ship_firstname = $paypal-> firstname;
$paypal->ship_lastname = $paypal-> lastname;
$paypal->ship_city = $paypal-> city;
$paypal->ship_state = $paypal-> state;
$paypal->ship_country_code = $paypal-> country_code;
$paypal->ship_zip = $paypal-> zip;
$paypal->credit_card_type = POST( 'card_type' );
$paypal->credit_card_number = POST( 'card_number' );
$paypal->exp_month = POST( 'card_month' );
$paypal->exp_year = POST( 'card_year' );
$paypal->cvn = POST( 'cvn' );
$paypal->amount = number_format((float)$Subscription->total, 2);
//$paypal->items_amount = number_format((float)$Subscription->price, 2);
$paypal->shipping_amount = 0;
//$paypal->tax_amount = number_format((float)$Subscription->taxes, 2);
$paypal->currency_code = 'CAD';
$paypal->prepare_checkout_request();
$paypal->process_request();
$paypal->interpret_response();
Looking at the Paypal documentation I found these parameters that should add the recurring feature to the current payment:
PROFILESTARTDATE
BILLINGPERIOD
BILLINGFREQUENCY
AMT
How could I fit these in the current structure to, for example, make it charge every 3 years?
Thanks for any info that could guide me!
PS, for this, do customers need a Paypal account? Or can they just put their credit card?
Related
I am using nopcommerce 3.5. I have added plugin of UPS of TransitInTime and Rate API. I want to get rates by calling UPS Rate API. I want all Rates in dropdown on page load.
So for the first I am using test application using webservices of RateWebReference and in which I get only one Rate but I want Rates for all shipping option.
Here is my code of RateWSClient.cs
RateService rate = new RateService();
RateRequest rateRequest = new RateRequest();
UPSSecurity upss = new UPSSecurity();
UPSSecurityServiceAccessToken upssSvcAccessToken = new UPSSecurityServiceAccessToken();
upssSvcAccessToken.AccessLicenseNumber = "CC....";
upss.ServiceAccessToken = upssSvcAccessToken;
UPSSecurityUsernameToken upssUsrNameToken = new UPSSecurityUsernameToken();
upssUsrNameToken.Username = "gi..";
upssUsrNameToken.Password = "Ch..";
upss.UsernameToken = upssUsrNameToken;
rate.UPSSecurityValue = upss;
RequestType request = new RequestType();
String[] requestOption = { "Rate" };
request.RequestOption = requestOption;
rateRequest.Request = request;
ShipmentType shipment = new ShipmentType();
ShipperType shipper = new ShipperType();
shipper.ShipperNumber = "A65V88";
RateWSSample.RateWebReference1.AddressType shipperAddress = new RateWSSample.RateWebReference1.AddressType();
String[] addressLine = { "", "", "" };
shipperAddress.AddressLine = addressLine;
shipperAddress.City = "";
shipperAddress.PostalCode = "30076";
shipperAddress.StateProvinceCode = "GA";
shipperAddress.CountryCode = "US";
shipperAddress.AddressLine = addressLine;
shipper.Address = shipperAddress;
shipment.Shipper = shipper;
ShipFromType shipFrom = new ShipFromType();
RateWSSample.RateWebReference1.AddressType shipFromAddress = new RateWSSample.RateWebReference1.AddressType();
shipFromAddress.AddressLine = addressLine;
shipFromAddress.City = "";
shipFromAddress.PostalCode = "30076";
shipFromAddress.StateProvinceCode = "GA";
shipFromAddress.CountryCode = "US";
shipFrom.Address = shipFromAddress;
shipment.ShipFrom = shipFrom;
ShipToType shipTo = new ShipToType();
ShipToAddressType shipToAddress = new ShipToAddressType();
String[] addressLine1 = { "", "", "" };
shipToAddress.AddressLine = addressLine1;
shipToAddress.City = "";
shipToAddress.PostalCode = "92262";
shipToAddress.StateProvinceCode = "";
shipToAddress.CountryCode = "US";
shipTo.Address = shipToAddress;
shipment.ShipTo = shipTo;
CodeDescriptionType service = new CodeDescriptionType();
//Below code uses dummy date for reference. Please udpate as required.
service.Code = "02";
shipment.Service = service;
PackageType package = new PackageType();
PackageWeightType packageWeight = new PackageWeightType();
packageWeight.Weight = "125";
CodeDescriptionType uom = new CodeDescriptionType();
uom.Code = "LBS";
uom.Description = "pounds";
packageWeight.UnitOfMeasurement = uom;
package.PackageWeight = packageWeight;
CodeDescriptionType packType = new CodeDescriptionType();
packType.Code = "02";
package.PackagingType = packType;
PackageType[] pkgArray = { package };
shipment.Package = pkgArray;
//Shipping Rate Chart
// ShipmentRatingOptionsType SRO = new ShipmentRatingOptionsType();
//SRO.RateChartIndicator = "";
//shipment.ShipmentRatingOptions= SRO;
//rateRequest.Shipment = shipment;
ShipmentRatingOptionsType SRO = new ShipmentRatingOptionsType();
SRO.NegotiatedRatesIndicator = "";
shipment.ShipmentRatingOptions = SRO;
rateRequest.Shipment = shipment;
System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
Console.WriteLine(rateRequest);
RateResponse rateResponse = rate.ProcessRate(rateRequest);
Console.WriteLine("The transaction was a " + rateResponse.Response.ResponseStatus.Description);
Console.WriteLine("Total Shipment Charges " + rateResponse.RatedShipment[0].TotalCharges.MonetaryValue + rateResponse.RatedShipment[0].TotalCharges.CurrencyCode);
Console.ReadKey();
I have resolved this questions. So If you face this kind of problem don't forget to use
String[] requestOption = { "Shop" };
in place of
String[] requestOption = { "Rate" };
Then you will get rates for all shipping options.
I'm getting an error when trying to add a sales order to netsuite via PHP toolkit
My code:
<?php
require_once '../PHPToolkit/NetSuiteService.php';
$service = new NetSuiteService();
$so->itemList = new SalesOrderItemList();
$item = new SalesOrderItem();
$so = new SalesOrder();
$entityRR = new RecordRef();
$entityRR->internalId = 10731;
$entityRR->recordType = "customer";
$so->entity = $entityRR ;
$so->currency->internalId = 1;
$so->itemList = new SalesOrderItemList();
$soi = new SalesOrderItem();
$soi->item = new RecordRef();
$soi->item->internalId = 2551;
$soi->quantity = 1;
$pricelevelRR = new RecordRef();
$pricelevelRR->internalId = -1;
$pricelevelRR->recordType = "priceLevel";
$soi->price = $pricelevelRR;
$soi->rate = 55.3;
$so->itemList->item = $soi;
$so->subsidiary->internalId = 5;
$so->location->internalId = 9;
$shipAddress = "123 the street Hampton NY 11937 United States";
$billAddress = "123 The street Hampton NY 11937 United States";
$so->shippingAddress1 = $shipAddress;
$so->billingAddress = $billAddress;
$arr = get_defined_vars();
print_r($arr["so"]);
$request = new AddRequest();
$request->record = $so;
$addResponse = $service->add($request);
if (!$addResponse->writeResponse->status->isSuccess) {
echo "ADD ERROR";
exit();
} else {
echo "ADD SUCCESS, id " . $addResponse->writeResponse->baseRef->internalId;
}
?>
I get the add response of this
<platformCore:code>USER_ERROR</platformCore:code>
<platformCore:message>Could not calculate cost for the selected Realtime rate. Missing/Illegal
ShipTo/Address/StateProvinceCode</platformCore:message>
</platformCore:statusDetail></platformCore:status></writeResponse>
</addResponse></soapenv:Body></soapenv:Envelope>
I'm not quite sure why it would not be able to calculate the cost and also say shipping address is missing
I noticed that you are entering the shipping address as one whole text. Have you tried entering it per the address fields. NetSuite has fields of each part of the address: address1, address2, city, state and zip code.
It might be looking that those fields which is why it is returning an error.
This is an old question but for those who are searching, this is an issue with pricing groups, to add a custom amount you need to match this with a pricing group in NetSuite.
Customer Orders not being bound to Customer
Postby DrFeeling » Mon Jun 01, 2015 4:05 pm
Good Afternoon peeps, I'm currently developping a mobile app for opencart that will bridge both tecnologies.
Most of the stuff is already active but I have a problem regarding order histories.
So, when you purchase something, through the main site, the default template of opencart, it generates a order history, that you can see through the website (my orders) or through the admin page.
My problem is that, whenever someone purchases something from the app, the orders of that costumer arent uptaded.
Though they appear in the main admin window (the dashboard) , once you go to customer (sales -> customers -> customers) the order made by the app isnt listed in the myOrders part of that customer, making both the "my previous orders" and the order of that customer inexistent in that place, but they appear in the dashboard and the notification email is foward to the customer
Please help me, and thanks for the support :D
Only order 261 (which was made in the website) is bounded to its customer, the others arent, as you can see in the pic below
AM I missing a parameter or a validation when the checkout process happens?
http://s16.postimg.org/y2h9rg5fp/image.jpg
EDIT: My code to create a order:
public function end_order() {
if ($this->customer->isLogged() == true){
$data= array();
$datap = array();
$this->load->model('account/customer');
$this->load->model('quickcheckout/order');
$this->load->model('checkout/order');
$myArray = $_POST["formData"];
$treatedArray = array();
foreach($myArray as $value) {
$treatedArray[$value['name']] = $value['value'];
}
$email = $_POST["email"];
$delivery = $_POST["deladdress"];
$delivery = array_shift($delivery); // sobe um nivel as posiçoes do array, em vez de usar $array[0]['bla'] , usasse so $array['bla']
$data2 = array();
$data2 = $this->model_account_customer->getCustomerByEmail($email);
$Method = $_POST["PayMethod"];
$TotalCheckout = $_POST["TotalCheck"];
$IP = $_POST["IP"];
$Agent = $_POST["User"];
$Products = $_POST["Prod"];
$length = count($Products);
for ($i = 0; $i < $length; $i++) {
(int)$datap[$i]['product_id'] = $Products[$i]['Id'];
$datap[$i]['name'] = $Products[$i]['Name'];
$datap[$i]['model'] = $Products[$i]['modelo'];
(int)$datap[$i]['quantity'] = $Products[$i]['NItems'];
$datap[$i]['price'] = $Products[$i]['Preco'];
$datap[$i]['total'] = $Products[$i]['Total'];
$datap[$i]['tax'] = 0; //$Products[$i]['Tax'];
(int)$datap[$i]['reward'] = 0; //$Products[$i]['Reward'];
}
$url = $myurl;
$data['invoice_prefix'] = $this->config->get('config_invoice_prefix');
$data['store_id'] = $this->config->get('config_store_id');
$data['store_name'] = "Loja Teste";
$data['store_url'] = $url;
$data['firstname'] = $data2['firstname'] ;
$data['lastname'] = $data2['lastname'];
$data['email'] = $data2['email'];
$data['telephone'] = $data2['telephone'];
$data['fax'] = $data2['fax'];
$data['payment_firstname'] = $delivery['firstname'];
$data['payment_lastname'] = $delivery['lastname'];
$data['payment_company'] = $delivery['company'];
$data['payment_company_id'] = $delivery['company_id'];;
$data['tax_id'] = $delivery['tax_id'];
$data['payment_address_1'] = $delivery['address_1'];
$data['payment_address_2'] = $delivery['address_2'];
$data['payment_city'] = $delivery['city'];
$data['payment_postcode'] = $delivery['postcode'];
$data['payment_country'] = $delivery['country'];
$data['payment_country_id'] = $delivery['country_id'];
$data['payment_zone'] = $delivery['zone'];
$data['payment_zone_id'] = $delivery['zone_id'];
$data['payment_method'] = "Cash On Delivery";
$data['payment_code'] = 1;
$data['total'] = $TotalCheckout;
//NOTA: esta duas variaveis abaixo servem para tratar dos preços, alterar depois para quando a loja tiver opçoes de escolher preços
$data['language_id'] = (int)$this->config->get('config_language_id');
$data['accept_language'] = $this->request->server['HTTP_ACCEPT_LANGUAGE'];
$data['currency_id'] = (int)2;
$data['currency_code'] = "USD";
$data['currency_value'] = (float)1.00000000;
$data['ip'] = $IP;
$data['forwarded_ip'] = $IP;
$data['user_agent'] = $Agent;
$data['products'] = $datap;
(int)$order = $this->model_checkout_order->addOrder($data);
$this->model_checkout_order->confirm($order, 1 , $comment = '', $notify = false);
echo ("teste");
}
}
I'm attempting to take an order from WooCommerce using the Rest API, and add that information into NetSuite as a Sales Order. I can successfully grab the order information from WooCommerce, but I am unsuccessful when adding the order into NetSuite using the PHPToolkit. Here is what I have so far:
<?php
/*
* Add a customer to Netsuite.
*
* paramtypesmap
*
*/
require_once 'includes/functions.php';
// create array of fields
$itemArr = array();
$i = 0;
$service = new NetSuiteService();
$salesOrder = new SalesOrder();
$salesOrder->entity = new RecordRef();
$salesOrder->entity->internalId = 512;
$salesOrder->entity->type = 'customer';
$salesOrder->shipDate = formatDate('2014-10-06T07:12:57.000-07:00');
$service = new NetSuiteService();
$service->setSearchPreferences(false, 1000);
$siteCategory = new SearchMultiSelectField();
$siteCategory->operator = "anyOf";
$siteCategory->searchValue = array('internalId' => 512);
$search = new ItemSearchBasic();
$search->internalId = $siteCategory;
$request = new SearchRequest();
$request->searchRecord = $search;
$searchResponse = $service->search($request);
$products = $searchResponse->searchResult->recordList->record;
$salesOrder->itemList = new SalesOrderItemList();
$item = new SalesOrderItem();
$item->item = new RecordRef();
$item->item->internalId = 531;
$item->quantity = 1;
//removeEmpty($item->item);
//removeEmpty($item);
$item->price = new RecordRef();
$item->price->internalId = 1;
$item->amount = 55.3;
$salesOrder->itemList->item=array(0=>$item);
//Equivalent too print_r
pr($item);
//Equivalent too print_r
pr($salesOrder);
removeEmpty($salesOrder);
$request = new AddRequest();
$request->record = $salesOrder;
//$service->setFields($purchaseOrderFields);
$response = $service->add($request);
if (!$response->writeResponse->status->isSuccess) {
echo getErrors($response->writeResponse);
} else {
echo success($response->writeResponse->baseRef->internalId);
}
?>
I'm just trying to work from the ground up to see what fields are required and how to build them, however I keep getting this error when ran:
Please choose a child matrix item
I have spent the last couple of days attempting to try some Google Fu on the problem, but with my luck found nothing. Can anyone help me with this?
Based from the error message, you are trying to submit a Parent Matrix Item instead of the child. Verify it by checking the Item Record with internal id 531.
The best way to achieve correct internal ids is to import Matrix Items directly from NetSuite into WooCommerce as variable products. Assigning the internal id to each variation.
I am unable to get the shipping Addresses of my customers in the 'Transacton Details' page.
It's displaying the following message.
'We have no shipping address on file'
The issue mainly happens when users use PaypalPro (Direct Payment) option.
Can anyone help me in this issue.
Note:
This is my code corresponding to the DoDirectPayment Request.
class ProAuthorizeRequest extends AbstractRequest
{
protected $action = 'Authorization';
public function getData()
{
$data = $this->getBaseData('DoDirectPayment');
$this->validate('amount', 'card');
$this->getCard()->validate();
$data['PAYMENTACTION'] = $this->action;
$data['AMT'] = $this->getAmount();
$data['CURRENCYCODE'] = $this->getCurrency();
$data['INVNUM'] = $this->getTransactionId();
$data['DESC'] = $this->getDescription();
// add credit card details
$data['ACCT'] = $this->getCard()->getNumber();
$data['CREDITCARDTYPE'] = $this->getCard()->getBrand();
$data['EXPDATE'] = $this->getCard()->getExpiryMonth().$this->getCard()->getExpiryYear();
$data['STARTDATE'] = $this->getCard()->getStartMonth().$this->getCard()->getStartYear();
$data['CVV2'] = $this->getCard()->getCvv();
$data['ISSUENUMBER'] = $this->getCard()->getIssueNumber();
$data['IPADDRESS'] = $this->getClientIp();
$data['FIRSTNAME'] = $this->getCard()->getFirstName();
$data['LASTNAME'] = $this->getCard()->getLastName();
$data['EMAIL'] = $this->getCard()->getEmail();
$data['STREET'] = $this->getCard()->getAddress1();
$data['STREET2'] = $this->getCard()->getAddress2();
$data['CITY'] = $this->getCard()->getCity();
$data['STATE'] = $this->getCard()->getState();
$data['ZIP'] = $this->getCard()->getPostcode();
$data['COUNTRYCODE'] = strtoupper($this->getCard()->getCountry());
return $data;
}
}
For DoDirectPayment you need to also include the SHIPTO variables:
public function getData()
{
$data = $this->getBaseData('DoDirectPayment');
$this->validate('amount', 'card');
$this->getCard()->validate();
$data['PAYMENTACTION'] = $this->action;
$data['AMT'] = $this->getAmount();
$data['CURRENCYCODE'] = $this->getCurrency();
$data['INVNUM'] = $this->getTransactionId();
$data['DESC'] = $this->getDescription();
// add credit card details
$data['ACCT'] = $this->getCard()->getNumber();
$data['CREDITCARDTYPE'] = $this->getCard()->getBrand();
$data['EXPDATE'] = $this->getCard()->getExpiryMonth().$this->getCard()->getExpiryYear();
$data['STARTDATE'] = $this->getCard()->getStartMonth().$this->getCard()->getStartYear();
$data['CVV2'] = $this->getCard()->getCvv();
$data['ISSUENUMBER'] = $this->getCard()->getIssueNumber();
$data['IPADDRESS'] = $this->getClientIp();
$data['FIRSTNAME'] = $this->getCard()->getFirstName();
$data['LASTNAME'] = $this->getCard()->getLastName();
$data['EMAIL'] = $this->getCard()->getEmail();
$data['STREET'] = $this->getCard()->getAddress1();
$data['STREET2'] = $this->getCard()->getAddress2();
$data['CITY'] = $this->getCard()->getCity();
$data['STATE'] = $this->getCard()->getState();
$data['ZIP'] = $this->getCard()->getPostcode();
$data['COUNTRYCODE'] = strtoupper($this->getCard()->getCountry());
//shipping information as you want displayed on transaction details. name is a single field.
$data['SHIPTONAME'] = $this->getCard()->getFirstName() . " " . $this->getCard()->getLastName();
$data['SHIPTOSTREET'] = $this->getCard()->getAddress1();
$data['SHIPTOSTREET2'] = $this->getCard()->getAddress2();
$data['SHIPTOCITY'] = $this->getCard()->getCity();
$data['SHIPTOSTATE'] = $this->getCard()->getState();
$data['SHIPTOZIP'] = $this->getCard()->getPostcode();
$data['SHIPTOCOUNTRYCODE'] = strtoupper($this->getCard()->getCountry());
return $data;
}