About the issue
This is about create order api in Paypal. Documentation link is here I am trying to pass below payload, so that the request could have my return and cancel url and everything works perfectly.
"intent": "CAPTURE",
"purchase_units": [
{
"amount": {
"currency_code": "USD",
"value": "100.00"
}
}
],
"application_context" => [
"return_url" => "my return url",
"cancel_url" => "my cancel url"
]
Just the return and cancel url has gone deprerated in application_context.
To overcome this problem, I removed application_context
from payload and added payment_source
like below which has return and cancel url
"intent": "CAPTURE",
"purchase_units": [
{
"amount": {
"currency_code": "USD",
"value": "100.00"
}
}
],
"payment_source": {
"paypal": {
"experience_context": {
"return_url": "return Url",
"cancel_url": "cancel Url"
}
}
}
Now, it gives an error message – PAYPAL_REQUEST_ID_REQUIRED
I need to pass return and cancel url and at this stage I only need to create the request to let user go to checkout page. that’s it. I really don’t have any payment info yet.
6
Answers
https://developer.paypal.com/api/rest/reference/orders/v2/errors/
Add this param in your headers
To resolve the error message "PAYPAL_REQUEST_ID_REQUIRED", you need to including a unique identifier in the "request_id" field in the payload.
something like:
You may also verify that the return and cancel URLs provided in the payload are valid and accessible.
Inside your
payment_source
add"request_id": "YOUR_UNIQUE_REQUEST_ID"
Your system can generate this
request Id
yourself and must be unique to prevent getting error messageDUPLICATED_REQUEST_ID
See here in documentation https://developer.paypal.com/api/rest/requests
PayPal-Request-Id
"Optional. Contains a unique user-generated ID that the server stores for a period of time. Use this header to enforce idempotency on REST API POST calls. …."
You need request_id could you try including reference_id.
This error is when:
The request is not well-formed, is syntactically incorrect, or violates schema:
https://developer.paypal.com/api/rest/reference/orders/v2/errors/
I could solve it changing it for this sintaxis:
But I am using Guzzle client in PHP.
Add and pass the header key as "PayPal-Request-Id" and for value you can pass any unique ID. It has to be unique for every transaction.
Adding this header should fix issue for you.