Anentropic
Anentropic

Reputation: 33843

Getting 500 from PayPal Sandbox AdaptivePayments/Pay

I am trying to make an AdaptivePayments payment in Sandbox.

I keep getting response like this (JSON decoded to Python dict):

{u'error': [{u'category': u'Application',
   u'domain': u'PLATFORM',
   u'errorId': u'520002',
   u'message': u'Internal Error',
   u'severity': u'Error',
   u'subdomain': u'Application'}],
 u'responseEnvelope': {u'ack': u'Failure',
  u'build': u'32250686',
  u'correlationId': u'864242c1ece9f',
  u'timestamp': u'2017-06-02T04:29:08.091-07:00'}}

I have checked and re-checked my request body parameters and request headers, against the docs and also against other successful requests of this type we are already making from our server.

Sandbox can be flaky, but other requests are succeeding and the error has persisted for 24 hours so I think it is a problem with my request.

I'm using X-PAYPAL-REQUEST-DATA-FORMAT: NV and the request body looks like:

actionType=PAY&currencyCode=GBP&cancelUrl=<mysite/cancel>&returnUrl=<mysite/return>&requestEnvelope.errorLanguage=en_US&preapprovalKey=<preapp key>&receiverList.receiver(0).email=<an email address>&receiverList.receiver(0).amount=0.62

(with real urls and preapproval key substituted in)

Upvotes: 0

Views: 81

Answers (1)

Anentropic
Anentropic

Reputation: 33843

Well, I eventually found the problem.

It seems there is an issue with the particular preapproval key I was sending. Changing to a preapproval key from a successful request was enough to make it work.

I have to say it is very very disappointing that the PayPal API returns a 500 status in this case (indicating unhandled exception on their side) rather than a proper error.

Further experimenting showed that if I used a different currency (USD instead of GBP) with the bad preapproval I could get an informative error:

{u'error': [{u'category': u'Application',
   u'domain': u'PLATFORM',
   u'errorId': u'539012',
   u'message': u"The preapproval key hasn't been authorized yet",
   u'severity': u'Error',
   u'subdomain': u'Application'}],
 u'responseEnvelope': {u'ack': u'Failure',
  u'build': u'32250686',
  u'correlationId': u'4b6ec5f7a64b7',
  u'timestamp': u'2017-06-02T05:16:08.800-07:00'}}

But I don't see any reason why different currency should prevent this error being shown, it seems a bug in PayPal.

Upvotes: 0

Related Questions