Server Sandbox Execute Call returning Error 400 Bad Request

Hydrochicken
Contributor
Contributor

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:

(Post) 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.

 

 

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.