Вопрос

I'm trying to implement recurring payments with the Express Checkout NVP API. After a successful flow SetExpressCheckout -> redirect to PayPal and acception -> GetExpressCheckoutDetails -> CreateRecurringPaymentsProfile, when I try to obtain a new token by calling SetExpressCheckout (let's say when I try to repeat the flow for another user), I get an error:

{ TIMESTAMP: '2014-05-14T09:09:17Z',
  CORRELATIONID: '9072df3650d68',
  ACK: 'Failure',
  VERSION: '113',
  BUILD: '10958405',
  L_ERRORCODE0: '10413',
  L_SHORTMESSAGE0: 'Transaction refused because of an invalid argument. See additional error messages for details.',
  L_LONGMESSAGE0: 'The totals of the cart item amounts do not match order amounts.',
  L_SEVERITYCODE0: 'Error' }

If I delete PAYMENTREQUEST_0_AMT: 0 from the request, I get another error, but this one with a token (which is the same on each request):

{ TOKEN: 'EC-2U787650918701539',
  TIMESTAMP: '2014-05-14T09:13:09Z',
  CORRELATIONID: 'd3f276219cab9',
  ACK: 'Failure',
  VERSION: '113',
  BUILD: '10958405',
  L_ERRORCODE0: '10410',
  L_SHORTMESSAGE0: 'Invalid token',
  L_LONGMESSAGE0: 'Invalid token.',
  L_SEVERITYCODE0: 'Error' }

So PayPal gives me a token, but says it's invalid. I guess it's not a problem with arguments or their values, but with tokens. For some reason PayPal just stops to emit new tokens in response to SetExpressCheckout requests after the first successful flow.

The complete flow:

1) SetExpressCheckout

USR: [...],
PWD: [...],
SIGNATURE: [...],
VERSION: 113,
METHOD: 'SetExpressCheckout',
PAYMENTREQUEST_0_AMT: 0,
MAXAMT: 5.0,
L_BILLINGTYPE0: 'RecurringPayments',
L_BILLINGAGREEMENTDESCRIPTION0: [...],
REQCONFIRMSHIPPING: 0,
NOSHIPPING: 1,
BRANDNAME: [...],
EMAIL: [...],
LANDINGPAGE: 'Login',
cancelUrl: [...],
returnUrl: [...]

2) Redirect to https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=TOKEN where a user accepts the billing agreement.

3) GetExpressCheckoutDetails (credentials, METHOD and TOKEN from the step 1).

4) CreateRecurringPaymentsProfile

USR: [...],
PWD: [...],
SIGNATURE: [...],
VERSION: 113,
METHOD: 'CreateRecurringPaymentsProfile',
TOKEN: [from the step 1],
PAYERID: [from the step 3],
PROFILESTARTDATE: [ISO date string],
DESC: [...],
BILLINGPERIOD: 'Month',
BILLINGFREQUENCY: 1,
AMT: 5.0,
AUTOBILLOUTAMT: 'AddToNextBilling',
CURRENCYCODE: 'USD',
MAXFAILEDPAYMENTS: 1,
L_PAYMENTREQUEST_0_ITEMCATEGORY0: 'Digital',
L_PAYMENTREQUEST_0_NAME0: [...],
L_PAYMENTREQUEST_0_AMT0: 5.0,
L_PAYMENTREQUEST_0_QTY0: 1

That's it. I use node.js request to accomplish the requests.

Это было полезно?

Решение 2

I have solved my problem by sending GET requests instead of POST. Here are the final fields set and a function I use to send GET requests to PayPal API.

Другие советы

Are you absolutely sure the request you provided for the second time around is correct? It seems like there must be something happening that you're unaware of, or some data must be getting included in that request that we're not seeing here..?? Maybe your log is saving from the original request (via a session or something) but the second one that's failing is actually a new request with additional parameters that is getting sent to PayPal but not what's getting saved in your log..??

When I replicate your request on my test server it works as expected no matter how many times I repeat it.

The error you're getting about cart totals only shows up when the following is NOT true.

AMT = ITEMAMT + SHIPPINGAMT + HANDLINGAMT + TAXAMT

When I add items to the same request, but purposefully make the prices not add up, then I get the error you're showing that you're getting on the second time through. You can see that here.

So the curious thing is that the request you're showing for that second time around doesn't have any item or amount info at all other than a MAXAMT just like the first one had. You are sending an amount of 0.00, though, which means if shipping, handling, tax, or any item were added with a price you would end up with the error you're getting.

Are you sure one of those parameters aren't somehow getting included in the request that your log isn't catching somehow..?? Is that a raw dump of exactly what gets passed into your HTTP request?

The fact of the matter is there has to be something that PayPal's server is seeing that would cause it to trigger this error, and I've never once seen that error when it wasn't a simple miscalculation of those values.

If you can't track anything like that down you'll need to submit this to PayPal MTS. I wouldn't even bother explaining all of this info about going around a second time, though. Simply provide the raw API request and response that failed to them, and question the fact that you're getting such an error when you're not even including any amount or item details in your request.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top