Update order details

DocsCurrentLast updated: March 31st 2023, @ 7:55:03 am

For increased flexibility when obtaining payments from buyers, you can update an existing order. Updating orders allows you to:

  • Determine additional amounts, including shipping and tax.
  • Capture a different total amount without the payer re-approving the order.
  • Update fields, such as shipping address, after collecting them from the payer.

Know before you code

This feature modifies an existing advanced Checkout integration and uses the following:

1. Show a Continue button

If you update the final amount of the order after the payer approves the payment, or update other amount fields, such as shipping or tax, show a Continue button during checkout instead of a Pay Now button. A Continue button indicates to the payer that the amount or other details might change before they complete the order.

To show a Continue button, add commit=false in the script tag as shown in the following example:

1<script src="https://www.paypal.com/sdk/js?client-id=CLIENT-ID&commit=false">

Tip: Using commit=false reduces the number of payment methods that are shown to your payer because not all funding sources can be used when modifying the order. When possible, determine the final amount before the payer approves the transaction, and avoid using PATCH.

2. Update order details

Before you capture the money from the order, call the Orders API on your server with the order ID. You can pass in a different amount, invoice_id, and custom_id. See the following code sample.

1curl -v -X PATCH 'https://api-m.sandbox.paypal.com/v2/checkout/orders/5O190127TN364715T' \
2 -H "Authorization: Bearer ACCESS-TOKEN" \
3 -d '[
4 {
5 "op": "add",
6 "path": "/purchase_units/@reference_id=='PUHF'/invoice_id",
7 "value": {
8 "integration_artifact": "INV-HighFashions"
9 }
10 }