- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey,
I'm facing some problem like this:
im trying to integrate paypal payments in my website through server side request. server is written in python and the flow goes like this:
1. asking for token with client_id and client_secret
'https://api.sandbox.paypal.com/v1/oauth2/token'
2. create payment request
"https://api.sandbox.paypal.com/v1/payments/payment/"
with the given token and redirect the client to the approval page with the given url -
{
"href": "https://api.sandbox.paypal.com/v1/payments//cgi-bin/webscr?cmd=_express-checkout&token=EC-60385559L1062554J",
"rel": "approval_url",
"method": "REDIRECT"
},
from the last respone (came back from create payment request).
3. now the shown page on the client side is paypal payments page, the client click the button to approve the payment, send request to the server
to execute new request.
on the server side im executing this request:
url = "https://api.paypal.com/v1/payments/payment/" +paymentId+ "/execute"
headers = {
'Content-Type': 'application/json',
"Authorization": "Bearer" + " " + accessToken,
}
dataPayment ={
"payer_id":payerId
}
and now i'm facing a problem:
im always getting this response
status 401
'{"error":"invalid_token","error_description":"The token passed in was not found in the system"}'
i tried using the token from the first request, i tried making another token request before make "execute" request, but im facing the same error over and over.
I'll appreciate your help,
thanks in advance.
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Look at the URL's that your using.
In the first few requests, requesting authorization and token your submitting the requests to "api.sandbox.paypal.com" but when you go to execute the payment, your submitting them to "api.paypal.com". You can't create a payment request within one environment and then attempt to execute it in another, hence the token error.
Was my post helpful? If so, please give me a kudos!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Look at the URL's that your using.
In the first few requests, requesting authorization and token your submitting the requests to "api.sandbox.paypal.com" but when you go to execute the payment, your submitting them to "api.paypal.com". You can't create a payment request within one environment and then attempt to execute it in another, hence the token error.
Was my post helpful? If so, please give me a kudos!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Multiparty payment API - Partner Platform Access in REST APIs
- IPN requests not reaching the listener in REST APIs
- API approved order not forwarding to PayPal in Sandbox Environment
- Need help to integrate PayPal Standard Checkout with Adyen? in PayPal Payments Standard
- I want to implement subscription functionality. in REST APIs