2

In implementing a server Paypal integration, the POST Create call works correctly to https://api.sandbox.paypal.com/v1/payments/payment with the response object matching that found in the API. The server successfully returns the result to the Client, and res.id for the .then(res) function of paypal.request.post is: PAY-76T970067E989851JLPLCMKA

After the user authorizes payment, the client sends a request to my server's execute endpoint with a payload of:

{ "paymentID" : "PAY-76T970067E989851JLPLCMKA", "payerID" : "3LSD3Q8J7T3ZL" } 

The server then remodels the payload for a query to paypal's POST Execute endpoint as follows:

headers:

Content-Type = "application/json" Authorization = "Bearer " + accessToken // checked not expired 

and a body payload of:

{"payer_id" : "3LSD3Q8J7T3ZL"} 

The post is then made to:

https://api.sandbox.paypal.com/v1/payments/payment/PAY-76T970067E989851JLPLCMKA/execute

at which point, the paypal server responds with: The remote server returned an error: (400) Bad Request.

Form what I can see, this matches the API requirements outlined here: https://developer.paypal.com/docs/api/payments/v1/#payment_execute

As a side note, I setup an endpoint on my own server to check the headers and JSON payload being submitted to the Paypal execute endpoint are correct.

Any suggestions would be greatly appreciated.

1 Answer 1

2

Resolved: Although the error is being returned when calling the Paypal's Execute endpoint, the problem actually resides in the Create payload. The soft_descriptor property submitted to the Create endpoint must be unique, just like the invoice_number property. Both of these values are found in the Transaction object, as shown here:

https://developer.paypal.com/docs/api/payments/v1/#definition-transaction.

Really, the error should be caught when creating the payment and not when executing it, but, hopefully this helps someone else.

Note to Paypal: A bit more information in the API would have saved a lot of headaches.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.