Update Order Details

SDKLegacyLast updated: June 20th 2023, @ 8:44:12 pm


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.

Note: This feature assumes you have completed a basic Smart Payment Buttons integration.

1. Update the script tag

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, change the PayPal script tag to pass commit=false.

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

This 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.

Note: Using commit=false reduces the number of Smart Payment Buttons 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 using PATCH.

2. Patch the transaction

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, and custom_id. See the following code sample for the list of fields that you can modify.

  1. Set up your server to make calls to PayPal
  2. Set up your server to receive a call from the client with the order ID
  3. Call PayPal to patch the order
  4. Handle any errors from the call
  5. Return a successful response to the client

For the full API reference, and example responses, see the Orders PATCH API reference.

3. Test and go live

Follow the steps in the basic integration to test your integration and go live.