facilitatorAccessToken to verify transaction details (PERMISSION_DENIED)

Viewed 979

Brand new to PayPal, tinkering with sandbox. My test orders are going through OK.

I would like to verify orders from my server and handle the provisioning tasks in the background for successful orders.

onApprove: function(data, actions) {
// data has things that are of interest, see below.
....
}

data has :

{
  "orderID": "4P1187891ORDERID",
  "payerID": "4MEHE6UPAYERID",
  "paymentID": null,
  "billingToken": null,
  "facilitatorAccessToken": "aHR0cHM6Ly9hcGkuc2FFACILITATORACCESSTOKENtL3YyL2NoZWNrb3V0L29yZGVycy80UDExODc4"
}

Their doc says this is how i can get the transaction details:

curl -v -X GET https://api.sandbox.paypal.com/v2/checkout/orders/5O190127TN364715T \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Access-Token"

So I carve my curl command as:

curl -v -X GET https://api.sandbox.paypal.com/v2/checkout/orders/4P1187891ORDERID \
-H "Content-Type: application/json" \
-H "Authorization: Bearer aHR0cHM6Ly9hcGkuc2FFACILITATORACCESSTOKENtL3YyL2NoZWNrb3V0L29yZGVycy80UDExODc4"

I use the facilitatorAccessToken as the Access-Token in curl above, and it is failing as:

{"name":"NOT_AUTHORIZED","details":[{"issue":"PERMISSION_DENIED","description":"You do not have permission to access or perform operations on this resource."}],"message":"Authorization failed due to insufficient permissions.","debug_id":"420XXXXX03","links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-PERMISSION_DENIED","rel":"information_link"}]}  

Has anyone suffered this before? I am assuming facilitatorAccessToken can be used as Access-Token to get Transaction Details - is this not the case?

1 Answers

Has anyone suffered this before? I am assuming facilitatorAccessToken can be used as Access-Token to get Transaction Details - is this not the case?

That's not the case. See "a curl command" on this page: https://developer.paypal.com/docs/api/overview/#get-an-access-token

Since you have a server doing processing with the data, you ought to be using a server-based integration for order creation and capture. You'll need two routes, one for 'Create Transaction' and one for 'Capture Transaction', documented here. Once you have those two routes, pair them with this approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server

Related