Update order details

DocsCurrentAdvancedLast updated: May 24th 2023, @ 6:14:20 pm


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:

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:

  1. 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 using PATCH.

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

    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'/invoice_id",
    "value": {
      "integration_artifact": "INV-HighFashions"
    }
      }
    ]'