I am getting an "Uncaught Error: Expected an order id to be passed"

C_Cataldo
Contributor
Contributor

I am getting an "Uncaught Error: Expected an order id to be passed" back even though I see an id being returned, and there are no errors in the event log for the Paypal sandbox request that was made.  

 

JS return from createOrder:

acktrue
dataObject { id: "4R111128JP953492S" }
id"4R111128JP953492S"

 

Corresponding event log entry:

11 Ma[Removed. Phone #s not permitted]/td>201 OK1ee5fb9ac41c3

POST /v2/checkout/orders

 

 

 

Here is the JSON data packet sent:

 

{
"application_context": {
"cancel_url": "",
"return_url": "",
"user_action": "PAY_NOW"
},
"intent": "CAPTURE",
"purchase_units": [
{
"amount": {
"breakdown": {
"discount": {
"currency_code": "USD",
"value": "0.00"
},
"item_total": {
"currency_code": "USD",
"value": "25.00"
},
"shipping": {
"currency_code": "USD",
"value": "6.43"
},
"tax_total": {
"currency_code": "USD",
"value": "1.50"
}
},
"currency_code": "USD",
"value": "32.93"
},
"description": "Test Business",
"invoice_id": "353781",
"items": [
{
"name": "Eagle Premier 25 Tooth Odometer Gear",
"quantity": "1",
"unit_amount": {
"currency_code": "USD",
"value": "25.00"
}
}
]
}
]
}

 

And the response:

 

{
"id": "4R111128JP953492S",
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/4R111128JP953492S",
"method": "GET",
"rel": "self"
},
{
"href": "https://www.sandbox.paypal.com/checkoutnow?token=4R111128JP953492S",
"method": "GET",
"rel": "approve"
},
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/4R111128JP953492S",
"method": "PATCH",
"rel": "update"
},
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/4R111128JP953492S/capture",
"method": "POST",
"rel": "capture"
}
],
"status": "CREATED"
}

 

Login to Me Too
1 REPLY 1

MTS_Jennifer
Moderator
Moderator

Hi @C_Cataldo,

Thank you for posting to the PayPal Merchant Community.

Here are a few things to remember when creating and capturing orders:

  • You must create an access token and pass an access token with every request
  • Orders must be authorized
  • Orders expire within 3 hours if not authorized

If you create an order, and attempt to capture the order without an access token (authorization header), you will receive an AUTHENTICATION_FAILURE error message.

If you capture an order without it being authorized, you will receive an error message ORDER_NOT_APPROVED.

If you attempt to capture an order that is over 3 hours old you will receive an error of RESOURCE_NOT_FOUND.

Make certain that when you create your order, you go through the sandbox buyer checkout process (you may need to paste the url into a browser).

After approving the order, capture the order, ensuring that you have an access token in the authorization header (to avoid order id errors).

 

Thank you,

Jennifer

MTS

PayPal

Login to Me Too

Haven't Found your Answer?

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