per-item details ci-merchant and PayPalExpress - paypal

I am using ci-merchant and I want to do my cart checkout with PayPal Express.
This is the code I am using:
$this->load->library('merchant');
$this->merchant->load('paypal_express');
$settings = $this->merchant->default_settings();
$settings = array(
'username' => 'bla bla bla.gmail.com',
'password' => 'bla bla bla',
'signature' => 'bla bla bla',
'test_mode' => true);
$this->merchant->initialize($settings);
$params =array(
'amount' => $this->cart->format_number($this->cart->total()),
'currency' => 'EUR',
'return_url' => 'https://www.example.com/checkout/payment_return/123',
'cancel_url' => 'https://www.example.com/checkout',
'description' => 'Esto es desc'
);
$response = $this->merchant->purchase($params);
With the above code I am being redirected to PayPal just fine, but at the items column I only see one unique item.
Now I would like to add per-item description, qty and price. But I don't know the where to include my items array, and wich format should I use. I can't find it on ci-merchant docs. Can anybody explain me?

You just need to setup your $params to include all of the fields you would need to make it work, and you need to make sure you're using version 63.0 or later.
It can be a little tricky, though, because any Express Checkout flow could include more than 1 payment, and each payment included could include more than 1 item, so you'll end up adding 0,1,2, etc. to params.
Here's a sample of SetExpressCheckout with 1 payment that has 2 items on it.
[REQUESTDATA] => Array
(
[USER] => ***
[PWD] => ***
[VERSION] => 97.0
[BUTTONSOURCE] => AngellEYE_PHPClass
[SIGNATURE] => ***
[METHOD] => SetExpressCheckout
[MAXAMT] => 200.00
[RETURNURL] => http://paypal.angelleye.com/standard/samples/DoExpressCheckoutPayment.php
[CANCELURL] => http://paypal.angelleye.com/paypal/class/cancel.php
[ALLOWNOTE] => 1
[HDRIMG] => http://paypal.angelleye.com/images/hdrimg.jpg
[SOLUTIONTYPE] => Sole
[LANDINGPAGE] => Billing
[BRANDNAME] => Angell EYE
[CUSTOMERSERVICENUMBER] => 555-555-5555
[BUYEREMAILOPTIONENABLE] => 1
[PAYMENTREQUEST_0_AMT] => 100.00
[PAYMENTREQUEST_0_CURRENCYCODE] => USD
[PAYMENTREQUEST_0_ITEMAMT] => 80.00
[PAYMENTREQUEST_0_SHIPPINGAMT] => 15.00
[PAYMENTREQUEST_0_TAXAMT] => 5.00
[PAYMENTREQUEST_0_DESC] => This is a test order.
[PAYMENTREQUEST_0_NOTETEXT] => This is a test note before ever having left the web site.
[PAYMENTREQUEST_0_PAYMENTACTION] => Sale
[L_PAYMENTREQUEST_0_NAME0] => Widget 123
[L_PAYMENTREQUEST_0_DESC0] => Widget 123
[L_PAYMENTREQUEST_0_AMT0] => 40.00
[L_PAYMENTREQUEST_0_NUMBER0] => 123
[L_PAYMENTREQUEST_0_QTY0] => 1
[L_PAYMENTREQUEST_0_ITEMURL0] => http://www.angelleye.com/products/123.php
[L_PAYMENTREQUEST_0_ITEMCATEGORY0] => Digital
[L_PAYMENTREQUEST_0_NAME1] => Widget 456
[L_PAYMENTREQUEST_0_DESC1] => Widget 456
[L_PAYMENTREQUEST_0_AMT1] => 40.00
[L_PAYMENTREQUEST_0_NUMBER1] => 456
[L_PAYMENTREQUEST_0_QTY1] => 1
[L_PAYMENTREQUEST_0_ITEMURL1] => http://www.angelleye.com/products/456.php
[L_PAYMENTREQUEST_0_ITEMCATEGORY1] => Digital
)
That results in the following when redirected to PayPal..

CI Merchant doesn't support listing order items in PayPal out of the box. There is a pull request which supports this, but it won't be merged into master until we work around some tax calculation and rounding issues.
Until it's supported officially, you may want to try using the forked version to achieve this, or simply edit the PayPal driver yourself to pass through the item data.

Related

Paypal (NVP APIs) how to discount for the order?

For example, this is my request paramaters,the order total is 270.00, if I want to use a coupon($10.00) to discount this order, than the order total must be 260.00, but now, I can't find any about discount AMT parameter in this api (https://developer.paypal.com/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/), I neglect it?
Array(
[PAYMENTREQUEST_0_CURRENCYCODE] => USD
[PAYMENTREQUEST_0_PAYMENTACTION] => Sale
[PAYMENTREQUEST_0_AMT] => 270.00
**[some parameter? DISCOUNT_AMT ?] => 10.00 // have this parameter ??**
[PAYMENTREQUEST_0_ITEMAMT] => 219.00
[PAYMENTREQUEST_0_SHIPPINGAMT] => 39.00
[PAYMENTREQUEST_0_HANDLINGAMT] => 12.00
[L_PAYMENTREQUEST_0_AMT0] => 219.00
[L_PAYMENTREQUEST_0_QTY0] => 1
[L_PAYMENTREQUEST_0_NAME0] => Goods title
[L_PAYMENTREQUEST_0_DESC0] => Goods description
);
Sorry about my poor English, thanks for buddies.
You will need to add the discount as an additional line item with a negative value and then adjust the ITEMAMT and AMT accordingly.
Array(
[PAYMENTREQUEST_0_CURRENCYCODE] => USD
[PAYMENTREQUEST_0_PAYMENTACTION] => Sale
[PAYMENTREQUEST_0_AMT] => 260.00
[PAYMENTREQUEST_0_ITEMAMT] => 209.00
[PAYMENTREQUEST_0_SHIPPINGAMT] => 39.00
[PAYMENTREQUEST_0_HANDLINGAMT] => 12.00
[L_PAYMENTREQUEST_0_AMT0] => 219.00
[L_PAYMENTREQUEST_0_QTY0] => 1
[L_PAYMENTREQUEST_0_NAME0] => Goods title
[L_PAYMENTREQUEST_0_DESC0] => Goods description
[L_PAYMENTREQUEST_0_AMT1] => -10.00
[L_PAYMENTREQUEST_0_QTY1] => 1
[L_PAYMENTREQUEST_0_NAME1] => Discount
[L_PAYMENTREQUEST_0_DESC1] => Coupon Code ABC123
);

(Salesforce Force.com REST API) How do I determine which products are associated with opportunities?

I'm using the Salesforce Force.com REST API. I need to determine which Products (Product2) are associated with Opportunities (Opportunity). Thus far, I've been unable to make the connection.
In the Salesofrce UI, opportunities can be associated with pricebooks and products. Pricebooks contain products, but it is also possible to associate products with an opportunity directly.
Querying an opportunity via the API yields the following:
Array
(
[0] => Array
(
[attributes] => Array
(
[type] => Opportunity
[url] => /services/data/v33.0/sobjects/Opportunity/xxxxxxxxxxxxxxxx
)
[Id] => xxxxxxxxxxxxxxxx
[IsDeleted] =>
[AccountId] => xxxxxxxxxxxxxxxxx
[Name] => Some Name
[Description] =>
[StageName] => Closed Won
[Amount] => 650
[Probability] => 100
[CloseDate] => 2012-04-12
[Type] => New Business
[NextStep] => A string
[LeadSource] => something
[IsClosed] => 1
[IsWon] => 1
[ForecastCategory] => Closed
[ForecastCategoryName] => Closed
[CampaignId] =>
[HasOpportunityLineItem] => 1
[Pricebook2Id] => xxxxxxxxxxxxxxxxxxxxx
[OwnerId] => xxxxxxxxxxxxxxxxxxx
[CreatedDate] => 2012-12-30T20:17:35.000+0000
[CreatedById] => xxxxxxxxxxxxxxxxxxxxxxxxxxx
[LastModifiedDate] => 2015-05-22T15:20:18.000+0000
[LastModifiedById] => xxxxxxxxxxxxxxxxxxxxxxxx
[SystemModstamp] => 2015-05-22T15:20:18.000+0000
[LastActivityDate] =>
[FiscalQuarter] => 1
[FiscalYear] => 2015
[Fiscal] => 2015 1
[LastViewedDate] => 2015-06-03T14:38:03.000+0000
[LastReferencedDate] => 2015-06-03T14:38:03.000+0000
[SyncedQuoteId] =>
[Type_of_Deal__c] => Monthly Contract Count
[Number_of_Contracts__c] => 999
[Fee_Per_Contract__c] => 999
[Installation_Fee__c] =>
[Roof_Top_Fee__c] =>
[LID__LinkedIn_Company_Id__c] =>
[inclusion_type__c] => inclusion type
[Total_Contract_Term__c] => 999
[Monthly_Value_of_Fee_Per_Contract__c] => 999
[Total_Value_of_Fee_Per_Contract__c] => 999
[Total_Value_of_Roof_Top_Fee__c] => 0
[Monthly_Fidels_Revenue__c] => 999
[Total_Value_of_Deal__c] => 999
[Number_of_Roof_Tops__c] =>
[Monthly_Value_of_Roof_Top_Fee__c] => 0
[Installation_Date__c] => 2012-01-01
[Reason_if_Lost__c] =>
[Total_Monthly_Revenue__c] => 999
[Existing_Agency__c] => Service Group
[Number_of_Contracts_in_Last_Batch__c] => 999
[Agent_Name__c] => John Smith
[Total_Value_of_Agency_Revenue__c] => 9999
[Contract_Start_Date__c] => 2012-01-01
[Batch_Received__c] => Yes
[Administrator__c] =>
[Per_Contract__c] => 999
[Integration_type__c] =>
[Last_Batch_ID__c] =>
[Last_Batch_Date__c] =>
)
)
From which you can see that no Product2 data is available. There is however, a Pricebook2Id. One might assume that querying that specific pricebook would yield information on which products are associated with it. However, querying a specific pricebook yields the following:
Array
(
[0] => Array
(
[attributes] => Array
(
[type] => Pricebook2
[url] => /services/data/v33.0/sobjects/Pricebook2/xxxxxxxxxxxx
)
[Id] => xxxxxxxxxxxxxxxxxxxx
[IsDeleted] =>
[Name] => Company Price Book
[CreatedDate] => 2011-11-14T18:36:23.000+0000
[CreatedById] => xxxxxxxxxxxxxxxxxxx
[LastModifiedDate] => 2011-11-14T18:36:23.000+0000
[LastModifiedById] => xxxxxxxxxxxxxxxxxxxxxxx
[SystemModstamp] => 2011-11-14T18:36:23.000+0000
[LastViewedDate] => 2015-06-04T19:41:20.000+0000
[LastReferencedDate] => 2015-06-04T19:41:20.000+0000
[IsActive] => 1
[Description] =>
[IsStandard] =>
)
)
As you can see, no information about products is available from the pricebook. So my question is:
How do I determine which products are associated with opportunities using the Salesforce Force.com REST API?
There is an object called 'Opportunity Product'. you need to get that object as well and link the proper opportunity to product.
It's a many to many relation and not one to many so more than one product might be related to each opportunity and vise versa.

Multiple recurring profiles in one go using the NVP method return invalid token error

I'm trying to create multiple recurring profiles in one go using the NVP method with PayPal API version 112.0 ... the first profile works fine, I then call it again and I get an invalid token error. The billing agreement is all same as for the other successful profile.
Though it is clearly said in documentation that multiple profiles can be created with single payment. I am using expressCheckout. Please help on this.
Here is my code:
/this create profile array works well/
Array
(
[METHOD] => CreateRecurringPaymentsProfile
[TOKEN] => EC-4AW0867838N0385684F
[INITAMT] => 180.00
[AMT] => 180.00
[CURRENCYCODE] => USD
[PROFILESTARTDATE] => 2014-10-03T13:35:04Z
[BILLINGPERIOD] => Month
[BILLINGFREQUENCY] => 3
[PAYMENTACTION] => Sale
[DESC] => 1× 3 Description
[PAYERID] => WLCZLZ2R4K7RJ
[PROFILEREFERENCE] => 29301-1396535617
[BUTTONSOURCE] => Ubercart_ShoppingCart_EC_US
[NOTIFYURL] => mysite.com/uc_paypal/ipn/77301
[ITEMAMT] => 180.00
[SHIPPINGAMT] => 0.00
[TAXAMT] => 0.00
)
in the next iteration it creates this array(which return Paypal error: Invalid Token)
Array
(
[METHOD] => CreateRecurringPaymentsProfile
[TOKEN] => EC-4AW0867838N0385684F
[INITAMT] => 180.00
[AMT] => 180.00
[CURRENCYCODE] => USD
[PROFILESTARTDATE] => 2015-10-03T13:35:04Z
[BILLINGPERIOD] => Month
[BILLINGFREQUENCY] => 13
[PAYMENTACTION] => Sale
[DESC] => 1× 3 Description
[PAYERID] => WLCZLZ2R4K7RJ
[PROFILEREFERENCE] => 29301-1396535618
[BUTTONSOURCE] => Ubercart_ShoppingCart_EC_US
[NOTIFYURL] => mysite.com/uc_paypal/ipn/77301
[ITEMAMT] => 180.00
[SHIPPINGAMT] => 0.00
[TAXAMT] => 0.00
)

PayPal Express Checkout Shipping Address should not be editable

I have already spent a lot of hours to find an answer for my problem but unfortunately i can't find a soloution.
I implement PayPal (Express Checkout) in our Shop-System. In our shop, the customer enters his shipping address. I don't want the customer to get the option to change his shipping address in PayPal. I only want the shipping address to be displayed which was entered before.
For example, here is an express checkout implementation like I want it:
Shipping Address only displayed:
How can i make this possible?
I use the PayPalSDK for ASP.NET
In your SetExpressCheckout request you can add the ADDROVERRIDE parameter and set its value to 1. Then make sure to include the shipping address parameters in your SEC request as well.
What this will do is simply display the address you pass over to PayPal without the ability for the user to change it.
The value 1 indiciates that the PayPal pages should display the
shipping address set by you in the SetExpressCheckout request, not the
shipping address on file with PayPal. This does not allow the
customer to edit the address here. Must be 1 or 0
Here's a sample of an SEC request I just sent to the PayPal sandbox:
[REQUESTDATA] => Array
(
[USER] => *****
[PWD] => *****
[VERSION] => 97.0
[BUTTONSOURCE] => AngellEYE_PHPClass
[SIGNATURE] => *****
[METHOD] => SetExpressCheckout
[MAXAMT] => 200.00
[RETURNURL] => http://paypal.angelleye.com/standard/samples/DoExpressCheckoutPayment.php
[CANCELURL] => http://paypal.angelleye.com/paypal/class/cancel.php
[REQCONFIRMSHIPPING] => 0
[NOSHIPPING] => 1
[ALLOWNOTE] => 1
[ADDROVERRIDE] => 1
[BRANDNAME] => Angell EYE
[CUSTOMERSERVICENUMBER] => 555-555-5555
[BUYEREMAILOPTIONENABLE] => 1
[SURVEYENABLE] => 1
[BUYERREGISTRATIONDATE] => 2012-07-14T00:00:00Z
[PAYMENTREQUEST_0_AMT] => 100.00
[PAYMENTREQUEST_0_CURRENCYCODE] => USD
[PAYMENTREQUEST_0_ITEMAMT] => 80.00
[PAYMENTREQUEST_0_SHIPPINGAMT] => 15.00
[PAYMENTREQUEST_0_TAXAMT] => 5.00
[PAYMENTREQUEST_0_DESC] => This is a test order.
[PAYMENTREQUEST_0_SHIPTONAME] => Tester Testerson
[PAYMENTREQUEST_0_SHIPTOSTREET] => 123 Test Ave.
[PAYMENTREQUEST_0_SHIPTOCITY] => Kansas City
[PAYMENTREQUEST_0_SHIPTOSTATE] => MO
[PAYMENTREQUEST_0_SHIPTOZIP] => 64111
[PAYMENTREQUEST_0_SHIPTOCOUNTRY] => US
[PAYMENTREQUEST_0_SHIPTOPHONENUM] => 816-555-5555
[PAYMENTREQUEST_0_NOTETEXT] => This is a test note before ever having left the web site.
[PAYMENTREQUEST_0_PAYMENTACTION] => Sale
[L_PAYMENTREQUEST_0_NAME0] => Widget 123
[L_PAYMENTREQUEST_0_DESC0] => Widget 123
[L_PAYMENTREQUEST_0_AMT0] => 40.00
[L_PAYMENTREQUEST_0_NUMBER0] => 123
[L_PAYMENTREQUEST_0_QTY0] => 1
[L_PAYMENTREQUEST_0_ITEMURL0] => http://www.angelleye.com/products/123.php
[L_PAYMENTREQUEST_0_NAME1] => Widget 456
[L_PAYMENTREQUEST_0_DESC1] => Widget 456
[L_PAYMENTREQUEST_0_AMT1] => 40.00
[L_PAYMENTREQUEST_0_NUMBER1] => 456
[L_PAYMENTREQUEST_0_QTY1] => 1
[L_PAYMENTREQUEST_0_ITEMURL1] => http://www.angelleye.com/products/456.php
[L_PAYMENTREQUEST_0_ITEMCATEGORY1] => Digital
)
And here's what I see when I log in to PayPal as the buyer after this SEC call...

Paypal sandbox 'Pending' multicurrency

Im currently using PayPals rest api. When executing payment it is returning as 'Pending' and the reason its stating is 'Multi Currency'.
The reason behind this is because the default 'facilitators' account is set to US i need it to all be in GB. The problem is I can login to user-facilitators#email.co.uk's account on sandbox.paypal.co.uk. I'm entering the email and password (which is 100% correct) and It wont let me login to sandbox so I can change the currency preferences back to GBP.
Does anybody no why?
In order to log into a Sandbox Paypal account, you have to be logged into your Paypal Developer Account
as the default 'facilitators' account is set to US and you want to change it to other country. but this edit is not possible in sandbox.
so an alternate solution is to create an another sandbox account and set it to business account. set your desired country and then currency will be your country currency, automatically.
after doing this, use this business account for testing instead of that default 'facilitators' account.
like this you can create any number of business accounts for any country/currency.
hope this will help to you and understood.
Yes, once we register on Paypal developer site, as default, Paypal will issue us two default test account, one is merchant account and another is user test account. All there are fine.
But the problem is their default currency is US, and We can't change them.
When your Magento store's base currency has been set others, like AU, this issue definitely will come out with following system log:
[CURRENCYCODE] => AUD
[PAYMENTSTATUS] => Pending
[PENDINGREASON] => multicurrency
Create another merchant account and set the same currency with your Magento store, it will be fixed.
payment_paypal_express.log
2014-12-12T01:51:34+00:00 DEBUG (7): Array
(
[url] => https://api-3t.sandbox.paypal.com/nvp
[GetTransactionDetails] => Array
(
[TRANSACTIONID] => 15Y48062WM0910211
[METHOD] => GetTransactionDetails
[VERSION] => 72.0
[USER] => ****
[PWD] => ****
[SIGNATURE] => ****
[BUTTONSOURCE] => OneStepCheckout_SI_MagentoCE
)
[response] => Array
(
[RECEIVEREMAIL] => john.yin.au-facilitator#gmail.com
[RECEIVERID] => VQ37QYGD3SFPW
[EMAIL] => john.yin.au-buyer#gmail.com
[PAYERID] => LXDH2RT89NRAS
[PAYERSTATUS] => verified
[COUNTRYCODE] => US
[SHIPTONAME] => john h
[SHIPTOSTREET] => 33
[SHIPTOSTREET2] => esdfd re
[SHIPTOCITY] => ddw
[SHIPTOSTATE] => AL
[SHIPTOCOUNTRYCODE] => AU
[SHIPTOCOUNTRYNAME] => Australia
[SHIPTOZIP] => 34343
[ADDRESSOWNER] => PayPal
[ADDRESSSTATUS] => Confirmed
[INVNUM] => 100000036
[SALESTAX] => 0.00
[TIMESTAMP] => 2014-12-12T01:51:34Z
[CORRELATIONID] => 2ef746f5f1a77
[ACK] => Success
[VERSION] => 72.0
[BUILD] => 14077178
[FIRSTNAME] => Test
[LASTNAME] => Buyer
[TRANSACTIONID] => 15Y48062WM0910211
[TRANSACTIONTYPE] => cart
[PAYMENTTYPE] => instant
[ORDERTIME] => 2014-12-12T01:50:39Z
[AMT] => 44.00
[TAXAMT] => 0.00
[SHIPPINGAMT] => 0.00
[HANDLINGAMT] => 0.00
[CURRENCYCODE] => AUD
[PAYMENTSTATUS] => Pending
[PENDINGREASON] => multicurrency
[REASONCODE] => None
[PROTECTIONELIGIBILITY] => Eligible
[PROTECTIONELIGIBILITYTYPE] => ItemNotReceivedEligible,UnauthorizedPaymentEligible
[L_NAME0] => color swatch te
[L_NUMBER0] => ZP-D3241-WHITE-L
[L_QTY0] => 1
[L_TAXAMT0] => 0.00
[L_SHIPPINGAMT0] => 0.00
[L_HANDLINGAMT0] => 0.00
[L_CURRENCYCODE0] => AUD
[L_AMT0] => 44.00
)
[__pid] => 30696
)