Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

PayPal /v2/checkout/orders patch custom_id (update order)

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

{
  "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?

>Solution :

Set the value to the desired string…:

[
  {
    "op": "replace",
    "path": "/purchase_units/@reference_id=='PUHF'/custom_id",
    "value": "CUSTOM_ID"
  }
]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading