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

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
)

Related

PayPal DoCapture in Sandbox fails with 10609 error - Invalid TransactionID

Paypal's Sandbox API responds to a DoCapture with "Invalid TransactionID" error code 10609. The same operation works correctly in the PayPal live site. I think there might be some deprecated params that are rejected in the Sandbox, but accepted in the PayPal live site.
The ff. is POST data from IPN:
[mc_gross] => 1.05
[auth_exp] => 05:28:33 May 26, 2016 PDT
[protection_eligibility] => Ineligible
[payer_id] => SCBNBBCFDWQ54
[tax] => 0.00
[payment_date] => 05:28:33 Apr 26, 2016 PDT
[payment_status] => Pending
[charset] => windows-1252
[first_name] => SandboxStephen
[option_selection1] => Lc1tCoAwCAbgu3iCxtYHdpghtEKoUc2IEd09G_ulPq8oYYtPwh7hSuH0PMGYlMCYbrB_r8kUaK2JRXCuqc7JLzzLPxmEogPCcVEUllzZlKq-U95CFL-QhJtyPagb-ub9AA,,~7634f
[transaction_entity] => auth
[option_selection2] => VU7LDgIhEPuX-QACw_CavfoHxjPZAAdNBLO4h43x3wXjxfYybZNOVyZ-dUaG6wOWzooYnBZIQSiDQqH8upphvbe9PmMtJZcMS2YlpJF_ICLpA8rgR2DRqsFABq11qK1Gr9D82tK-baWmI6aWy3wxvMv5NC83tvR4661OJRlgeX8A~97b17
[option_selection3] => S7QytKoutjK3UspNLS5OTE9Vsi62MrBSUrKuBQA,~2c5b4
[option_selection4] => S7QytqoutjK3UkrPTCuJL8lXsi62MrBSAlGWUMG0ovxcJGFDA6h4am5iZg5cohYA~2aa63
[notify_version] => 3.8
[custom] =>
[payer_status] => verified
[business] => xxxxxxx#xxxxx
[quantity] => 1
[verify_sign] => AvzodxdQ1l47jbnC5iCE7iEjAVYEAnMT6fQE9TdHnShf4zX8V6L99Kpe
[payer_email] => xxxxxx#xxxx
[option_name1] => Transkey
[parent_txn_id] =>
[option_name2] => Syskey
[option_name3] => Message
[option_name4] => Gift
[txn_id] => 4R146799GX924083N
[payment_type] => instant
[remaining_settle] => 10
[auth_id] => 4R146799GX924083N
[last_name] => xxxxx
[receiver_email] => xxxxxxx#xxxxx
[auth_amount] => 1.05
[shipping_discount] => 0.00
[insurance_amount] => 0.00
[receiver_id] => F3XAHZBJYATHU
[pending_reason] => authorization
[txn_type] => web_accept
[item_name] => Test New Deal 2 (Topic)
[discount] => 0.00
[mc_currency] => USD
[item_number] =>
[residence_country] => US
[test_ipn] => 1
[shipping_method] => Default
[handling_amount] => 0.00
[transaction_subject] =>
[payment_gross] => 1.05
[auth_status] => Pending
[shipping] => 0.00
[ipn_track_id] => ff07a74b6ad10
The ff. are parameters for DoCapture:
[authorization_id] => 4R146799GX924083N
[amount] => 1.05
[invoice_id] => 9569
[currency] => USD
[CompleteCodeType] => Complete
[note] => Acuerdo de pago
The ff. is PayPal's response to DoCapture:
[AUTHORIZATIONID] => 4R146799GX924083N
[TIMESTAMP] => 2016-04-26T12:28:57Z
[CORRELATIONID] => 82d81683c3cc8
[ACK] => Failure
[VERSION] => 62
[BUILD] => 21669447
[L_ERRORCODE0] => 10609
[L_SHORTMESSAGE0] => Invalid transactionID.
[L_LONGMESSAGE0] => Transaction id is invalid.
[L_SEVERITYCODE0] => Error
I have tested the new PayPal security upgrades on the site and they work correctly. I specify a very old version (62) of the API, so that might be the problem, but I don't see what I need to change to get the Sandbox to work correctly.
Thanks.
It looks like you mix up the sandbox environment and live environment. You call DoCapture in the live environment, but the 4R146799GX924083N transaction is generated in sandbox environment.
When you call Docapture API, please make sure the API endpoint is https://api-3t.sandbox.paypal.com/nvp , the endpoint change to sandbox , not live.

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
);

Paypal IPN keeps failing - The totals of the cart item amounts do not match order amounts

We are using Woocommerce and Woocommerce Subscriptions. For some reason by default, Woocommerce Subscriptions (Reference Transactions) do not pass or include the Tax amount to Paypal. So I ended up modifying the class files and added in the field "TAXAMT" in the IPN.
However, when I did so, it is now giving us the error:
[L_ERRORCODE0] => 10413
[L_ERRORCODE1] => 10004
[L_SHORTMESSAGE0] => Transaction refused because of an invalid argument. See additional error messages for details.
[L_SHORTMESSAGE1] => Invalid Data
[L_LONGMESSAGE0] => The totals of the cart item amounts do not match order amounts.
[L_LONGMESSAGE1] => This transaction cannot be processed.
[L_SEVERITYCODE0] => Error
[L_SEVERITYCODE1] => Error
Can anybody please help me identify what's missing or what is wrong here?
Below is the IPN request sent to paypal (via woocommerce paypal logs)
This is a recurring product. The product costs $7.70 and the Tax is $0.77 with a total of $8.47
[USER] => ****************
[PWD] => ****************
[SIGNATURE] => ********************************************************
[VERSION] => 124
[METHOD] => DoReferenceTransaction
[REFERENCEID] => B-4CR65046J0487452E
[BUTTONSOURCE] => WooThemes_Cart
[RETURNFMFDETAILS] => 1
[AMT] => 7.70
[CURRENCYCODE] => AUD
[INVNUM] => WC-5184
[PAYMENTACTION] => Sale
[NOTIFYURL] => https://affgo.co/go/wc-api/WC_Gateway_Paypal/
[CUSTOM] => {"order_id":5184,"order_key":"wc_order_56bad2660bf0f"}
[TAXAMT] => 0.77
[ITEMAMT] => 8.47
[L_PAYMENTREQUEST_0_NAME0] => Subscriptions → IMMag Monthly
[L_PAYMENTREQUEST_0_AMT0] => 7.70
[L_PAYMENTREQUEST_0_QTY0] => 1
[PAYMENTREQUEST_0_ITEMAMT] => 7.70
[PAYMENTREQUEST_0_SHIPPINGAMT] => 0.00
[PAYMENTREQUEST_0_TAXAMT] => 0.77

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
)

Paypal : invalid token only in DoExpressCheckoutPayment method

I'm starting to work with PayPal and my first work is to debug it on our website.
Actually when we go to the end of an order, it works fine but we get a stack in the logs : "Invalid token (#10410: Invalid Token)".
This happens when the doExpressCheckoutPayment is called and it seems like there's no token and no payerid so an error is thrown. All other information seem to be correctly filled.
Here's the debug result calling doExpressCheckoutPayment :
[DoExpressCheckoutPayment] => Array
(
[TOKEN] =>
[PAYERID] =>
[PAYMENTACTION] => Sale
[AMT] => 4.16
[CURRENCYCODE] => EUR
[BUTTONSOURCE] => Varien_Cart_EC_FR
[NOTIFYURL] => *
[RETURNFMFDETAILS] => 1
[ITEMAMT] => 3.36
[TAXAMT] => 0.80
[SHIPPINGAMT] => 0.00
[L_NUMBER0] => *
[L_NAME0] => *
[L_QTY0] => 1
[L_AMT0] => 4.10
[L_NUMBER1] =>
[L_NAME1] => Discount
[L_QTY1] => 1
[L_AMT1] => -0.74
[BUSINESS] =>
[EMAIL] => *
[FIRSTNAME] => *
[LASTNAME] => *
[MIDDLENAME] =>
[SALUTATION] =>
[SUFFIX] =>
[COUNTRYCODE] => *
[STATE] => *
[CITY] => *
[STREET] => *
[ZIP] => *
[PHONENUM] => *
[SHIPTOCOUNTRYCODE] => *
[SHIPTOSTATE] => *
[SHIPTOCITY] => *
[SHIPTOSTREET] => *
[SHIPTOZIP] => *
[SHIPTOPHONENUM] => *
[SHIPTOSTREET2] =>
[STREET2] =>
[SHIPTONAME] => *
[ADDROVERRIDE] => 1
[METHOD] => DoExpressCheckoutPayment
[VERSION] => 72.0
[USER] => ****
[PWD] => ****
[SIGNATURE] => ****
)
[response] => Array
(
[TIMESTAMP] => 2013-03-07T15:01:45Z
[CORRELATIONID] => 64adbc2375f59
[ACK] => Failure
[VERSION] => 72.0
[BUILD] => 5331358
[L_ERRORCODE0] => 10410
[L_SHORTMESSAGE0] => Invalid token
[L_LONGMESSAGE0] => Invalid token.
[L_SEVERITYCODE0] => Error
)
Problem is that just after this method is called, setExpressCheckout is called and it's a success so the order is correctly placed.
Here's the success response when calling setExpressCheckout :
[response] => Array
(
[TOKEN] => EC-5UG654898R029060W
[TIMESTAMP] => 2013-03-07T15:01:48Z
[CORRELATIONID] => 348b58c6200c1
[ACK] => Success
[VERSION] => 72.0
[BUILD] => 5331358
)
I don't understand why when doing a doExpressCheckoutPayment, a failure is thrown and when doing setExpressCheckout, no error is detected and the sale is accepted anyway....
Is there a problem in the order of the method call ? I mean, should setExpressCheckout not be called before doExpressCheckoutPayment ?
We're facing an other problem with PayPal and I hope that solving this problem will solve the other one....
Thanks you very much for your help guys !
Seb
The SetExpressCheckout should happen first -- the token you get back is what you redirect the customer's browser with, and when they return they'll have the token in the URL and that is when you can getExpressCheckoutDetails if you need to see their shipping address and associated info, and finally you run doExpressCheckoutPayment to commit the transactions.
To reiterate: You get a valid token from the setEC, you use this token in the redirect, you get this token back appended to the RETURNURL the customer returns to, and you reference this token in any subsequent getEC and doEC calls.