When updating a PayPal order using the REST API, we typically do it as below according to the documentation at https://developer.paypal.com/docs/api/orders/v2/#orders_patch
curl -v -X PATCH https://api-m.sandbox.paypal.com/v2/checkout/orders/5O190127TN364715T \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer access_token' \
-d '[
{
"op": "add",
"path": "/purchase_units/@reference_id==\'PUHF\'/shipping/address",
"value": {
"address_line_1": "2211 N First Street",
"address_line_2": "Building 17",
"admin_area_2": "San Jose",
"admin_area_1": "CA",
"postal_code": "95131",
"country_code": "US"
}
}
]'
However when trying to update the custom_id
or invoice_id
, it gives a validation error when trying to put a value in the "value" key since these do not represent an object like the example above.
I've tried using the key "integration_artifact" as seen in an example at https://developer.paypal.com/docs/multiparty/checkout/advanced/customize/update-order-details/ but this results in an error as well
curl -v -X PATCH https://api-m.sandbox.paypal.com/v2/checkout/orders/5O190127TN364715T \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer access_token' \
-d '[
{
"op": "replace",
"path": "/purchase_units/@reference_id==\'PUHF\'/custom_id",
"value": {
"integration_artifact": "CUSTOM_ID"
}
}
]'
The error
{
"name": "UNPROCESSABLE_ENTITY",
"details": [
{
"issue": "VALIDATION_ERROR",
"links": [],
"description": "VALIDATION_ERROR"
}
],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "fca96d06c1409",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-VALIDATION_ERROR",
"rel": "information_link"
}
]
}
What should I put in the value for custom_id/invoice_id when the value should just be a string?
Set the value to the desired string...:
[
{
"op": "replace",
"path": "/purchase_units/@reference_id=='PUHF'/custom_id",
"value": "CUSTOM_ID"
}
]