Update order details
DocsCurrentAdvancedLast updated: July 8th 2024, @ 3:10:57 am
Update order details to provide a unique buyer experience.
Know before you code
- These capabilities modify an existing checkout integration.
- Complete the steps in Get started to get the following sandbox account information from the Developer Dashboard:
- Your sandbox account login information
- Your access token
- These client-side and server-side integration capabilities use the following:
- PayPal JavaScript SDK
- Orders REST API — Create order and Update order
Update order details
This procedure applies to standard and advanced integrations.
For increased flexibility when obtaining payments from buyers, you can update the transaction after it has been set up. This allows you to:
- Determine additional amounts, including shipping and tax.
- Capture a different total amount, without needing the buyer to re-approve the transaction.
- Update fields, such as shipping address, after collecting them from the buyer.
To update order details, complete the following steps:
If you are updating the final amount of the transaction after the buyer approves the payment, or if you are updating other amount fields, such as shipping or tax, add
commit=false
in the script tag as shown in the following example:<script src="https://www.paypal.com/sdk/js?client-id=CLIENT_ID&commit=false"> </script>
Passing
commit=false
shows a Continue button during the buyer checkout experience rather than a Pay Now button, indicating to the buyer that the amount or other details might change before they complete the transaction.Tip: Using
commit=false
reduces the number of payment methods that are shown to your buyer, since not all funding sources can be used when modifying the transaction. When possible, determine the final amount before the buyer approves the transaction on PayPal, and avoid usingPATCH
.Before you capture the funds from the transaction, call the PayPal Orders API on your server with the order ID. You can pass in a different
amount
,invoice_id
, andcustom_id
. See the following code sample.curl -v -X PATCH https://api-m.sandbox.paypal.com/v2/checkout/orders/5O190127TN364715T \ -H "Content-Type: application/json" \ -H "Authorization: Bearer Access-Token" \ -H 'PayPal-Auth-Assertion: PAYPAL-AUTH-ASSERTION' \ -H 'PayPal-Partner-Attribution-Id: BN-CODE' \ -d '[ { "op": "add", "path": "/purchase_units/@reference_id=='PUHF'/invoice_id", "value": { "integration_artifact": "INV-HighFashions" } } ]'