Last updated

Update ongoing order


This page details how to handle cart updates and changes in country/locale for Kustom Checkout (KCO) orders.

How it’s done

If a customer modifies their basket, you must update the existing KCO order with the new items and amounts. Similar updates are needed if the customer changes their country or language. If changes happen on the same checkout page, suspend, update, and resume KCO for visual updates. KCO provides API callbacks for changes within the checkout snippet (e.g., country change). Track the KCO order_id to avoid creating new orders each time the page loads.

When a customer loads the page with an existing order_id in the session, fetch the order from KCO. If the order content has changed, update the order.

  • KCO orders are valid for 48 hours. After that, they expire.
  • If you receive a 4XX or 5XX error, create a new order.

Retrieve an Order

Use the order_id to retrieve the order from Kustom.

GET /checkout/v3/orders/<order_id>
Authorization: Basic pwhcueUff0MmwLShJiBE9JHA==
Content-Type: application/json

Read Order Response

Example JSON response:

{
  "order_id": "8cf27b55-53e8-6aba-9fb4-7c692e56ddee",
  "status": "checkout_complete",
  "purchase_country": "gb",
  "purchase_currency": "GBP",
  "locale": "en-GB",
  "billing_address": {
    "given_name": "Testperson-se",
    "family_name": "Approved",
    "email": "Testperson-se@kustom.co",
    // ... more address details
  },
  // ... more order details
}

Update the Order

Update the KCO order to reflect changes in the cart. Note that updates to billing_address and shipping_address are ignored after the customer provides initial data.

Updating Order Request

Example JSON request to update the order (with adding items):

POST /checkout/v3/orders/<order_id>
Authorization: Basic pwhcueUff0MmwLShJiBE9JHA==
Content-Type: application/json
{
"order_amount": 756682,
"order_tax_amount": 151336,
"order_lines": [
  {
    // ... details of the updated order lines
  }
]
}

Updating Order Response

Example JSON response after updating the order:

{
  // ... Updated order details
}

Update an Ongoing Checkout Order

To update an order while the customer is on the checkout page:

  1. Suspend the Checkout: Prevents customer input and displays a loading indicator.

    window._klarnaCheckout(function (api) {
        api.suspend();
    });
  2. Update the Order: Update the order details as needed.

  3. Resume the Checkout: Refreshes the order data, removing the loading indicator.

    window._klarnaCheckout(function (api) {
        api.resume();
    });