# Add confirmation page upsells

Enable Kustom Checkout confirmation-page upsell, supply product recommendations and handle order changes until the delayed confirmation push arrives.

Customers can add recommended products to their paid order without entering payment details
again. Kustom handles the widget, increased authorization and order updates. Your integration
supplies recommendations and keeps the order open for changes during the upsell window.

## Before you start

**Contact Kustom to enable upsell on your merchant account.**

**Upsell delays the confirmation push** until the window closes: ten minutes by default,
plus a minute's buffer. Order creation, stock reservations and emails triggered by the push
are delayed too.

The delay applies only when upsell is active for the order and its payment method supports
upsell. Kustom checks eligibility. Otherwise, the push fires immediately.

## Step by step

### 1. Turn it on

Enable per order for a staged rollout or A/B test:

```json
{
  "options": {
    "confirmation_page_upsell": true
  }
}
```

The flag can still be changed on an update, right up until the order reaches
`checkout_complete`.

Upsell can also be enabled through:

- **Setting `merchant_urls.upsell`.** An order carrying an upsell URL has upsell on, with or
  without the option.
- **Account-level enablement.** Kustom can turn upsell on for every eligible order on your
  merchant ID. Once that's set, `confirmation_page_upsell: false` doesn't opt an order out —
  ask Kustom to change the account setting instead.

### 2. Choose where recommendations come from

| | Curation in Kustom Portal | Your own endpoint |
|---|---|---|
| Effort | No development | Build and host an HTTP endpoint |
| How it works | Kustom imports your Google product feed and you pick the products to recommend | Kustom calls your endpoint and you return the products |
| Control | A fixed selection | Per order, dynamic, personalized |
| Best for | Getting started, a small set of evergreen add-ons | An existing recommendation engine or catalog-driven logic |

**Curation in Portal.** Connect your Google product feed under **Upsell** in
[Kustom Portal](https://portal.kustom.co/) and select products. Kustom filters out products
with a different currency, no stock, a price above the available authorization or an item
already in the order. Other cart contents and the selected shipping option don't affect
this fixed selection; use an endpoint for those rules.

**Your own endpoint.** Set `merchant_urls.upsell` and Kustom calls it before the
confirmation page loads:

```json
{
  "merchant_urls": {
    "upsell": "https://www.example.com/api/upsell"
  }
}
```

Portal-curated products take precedence when any survive filtering. Otherwise, Kustom calls
your endpoint. With neither source, it uses its own recommendation service.

**Respond in under 3 seconds.** The hard limit is **10 seconds**, with no retry. A slow or
failed response leaves the customer without an upsell widget.

A slow or failed response doesn't shorten the push delay. The full window is set at
completion, based on upsell settings and payment method eligibility.

### 3. Return recommendations

Kustom `POST`s an `upsell_request` and expects product lines in response. See the
[full contract](/checkout/use-cases/upsell-callback-contract/). Filter recommendations using:

- **`max_upsell_amount`** — the authorization headroom, in minor units. Filter to what fits. Anything above it will be blocked when the customer taps.
- **`purchase_currency` and `locale`** — price and describe correctly.
- **`billing_address` and `shipping_address`** — apply the right tax rate.
- **`selected_shipping_option`** — drop anything that would break the delivery method already chosen.

A minimal, valid response:

```json
{
  "upsell_lines": [
    {
      "name": "Baseball Cap",
      "reference": "CAP-SAND-001",
      "quantity": 1,
      "unit_price": 40000,
      "tax_rate": 2500,
      "total_amount": 40000,
      "total_tax_amount": 8000,
      "max_allowed_quantity": 3,
      "image_url": "https://www.example.com/images/cap-sand.jpg",
      "product_url": "https://www.example.com/products/cap-sand"
    }
  ],
  "last_upsell_time": "2024-01-01T12:05:00Z"
}
```

**Handle repeated calls.** Kustom calls your endpoint before confirmation loads and after
each added item. Make the handler idempotent and exclude items already in the order.

Return `upsell_lines: []` to show no widget at all. You'll still be called when
`upsell_possible` is `false`. An empty array is the correct answer then.

### 4. Decide when your system creates the order

The order can change until the upsell window closes. Choose when to create it in your system.

**Create on push (recommended).** Wait for the confirmation push, which carries the final
`order_lines`, including upsold items:

1. The payment is authorized and Kustom marks the checkout order `checkout_complete`.
2. Kustom redirects the customer to your confirmation page.
3. Your backend reads the checkout order but doesn't create an order yet.
4. You render the Kustom confirmation snippet.
5. Kustom fetches recommendations and shows the widget.
6. The customer adds items. Kustom increases the authorization and updates the checkout order.
7. The window closes and Kustom sends the confirmation push with the final `order_lines`.
8. Your backend creates the order once, from the push.

**Create on redirect.** Use this when you need an immediate record, for example to reserve
stock for high-value goods. Follow the same flow, with these changes:

1. On redirect, read the checkout order and create it in your system **on hold**.
2. When an item is added, Kustom runs `upsell_validation` if configured, increases the
   authorization and updates the order. It notifies `merchant_urls.upsell_notification`, or
   the response's `notification_uri` if that URL isn't set. Re-read the order through Order
   Management after each notification.
3. When the confirmation push arrives, read the final order and release the hold.

Keep the order updatable throughout the window. Wait for the push before sending a
confirmation email or releasing the order to the warehouse.

Either way, you can tell whether to expect a delayed push from `options.confirmation_page_upsell`
on the order, or from `upsell_possible` in the upsell request.

## Check that it works

In Playground, with upsell enabled on the account:

1. Create an order with `options.confirmation_page_upsell: true` and complete a purchase.
2. Your `merchant_urls.upsell` endpoint is called before the confirmation page renders, and the request carries `upsell_possible: true` and a non-zero `max_upsell_amount`.
3. The widget renders your recommendations, with images.
4. Adding an item doesn't ask for payment details, the order's `order_lines` grow and your endpoint is called again.
5. The confirmation push arrives **after** the window closes, carrying the final lines.
6. For a purchase where `upsell_possible` is `false`, no widget appears and the push arrives immediately.

To find what was upsold, diff the `order_lines` on the original checkout order against the
`order_lines` in the confirmation push. For a signal per item as it's added, set
`feedback_url` on each upsell line.

## Variations

**Validate each add.** Set `merchant_urls.upsell_validation` and Kustom asks before
processing an addition. The body is the ordinary order model plus `upsell_order_lines`,
the lines being requested. Return `2xx` to allow. Anything else blocks it.

```json
{
  "merchant_urls": {
    "upsell_validation": "https://www.example.com/api/upsell-validation"
  }
}
```

**Do not treat that response as final.** The authorization increase can still fail after
you approve. The confirmation push remains the source of truth.

**Close the widget early.** Return `last_upsell_time` in your upsell response and the widget
stops accepting additions at that moment. It doesn't bring the push forward: the push still
waits for the window configured on your account.

**Re-rating shipping after an add.** If your carrier pricing depends on the cart, either
pre-filter in your upsell endpoint so every candidate keeps the current shipping method
valid — the recommended route — or re-rate afterwards and handle a method change by your
own policy, optionally via the `shipping_option_update` callback.

**A/B testing.** Swap the `merchant_urls.upsell` endpoint whenever you like, or split traffic
with `options.confirmation_page_upsell`. Remember that curated Portal products take
precedence over an endpoint, so clear the curation to test an endpoint against it.

**Minimal confirmation.** Upsell is compatible with the `minimal_confirmation` GUI option
and overrides it automatically while the widget is shown.

## Troubleshooting

**The widget never appears.** Either the order [didn't qualify](/checkout/use-cases/upsell-callback-contract/#when-the-widget-is-shown), for example because of the payment method — check
`upsell_possible` — or there was nothing to show: your endpoint was too slow or returned no
lines, or every curated product was filtered out. All of these fail silently by design.

**Your endpoint is never called.** Your account has Portal-curated products, and they take
precedence. Remove the curation if you want the endpoint to decide.

**Additions are blocked.** They exceed the authorization. Pre-filter on `max_upsell_amount`.

**`selected_shipping_option` is missing.** It's present whenever the order has a selected
shipping option — set from the order's own `shipping_options` (the preselected one, else the
first) or by the [Shipping Assistant](/checkout/shipping/#shipping-assistant). An order that
carries no shipping options at all has nothing to report. Filter on your own shipping knowledge
instead.

**The push is late.** Kustom sets the account's upsell window, ten minutes by default. The
push follows about a minute later. The API can't change the window; `last_upsell_time`
closes the widget sooner but doesn't move the push.

**The push is late and you never enabled upsell.** Check whether the order carries
`merchant_urls.upsell`, or whether Kustom enabled upsell for your whole account. Either one
turns it on without the option.

**You want to show a free-shipping threshold in the widget.** Not supported. Apply
threshold logic on your side when you process the final order.

## Related

- [Upsell callback reference](/checkout/use-cases/upsell-callback-contract/) — every field of the request and the response
- [Confirmation and push](/checkout/integrate/confirmation-and-push/) — the push this page delays
- [Create an order](/checkout/integrate/create-order/) — where `options.confirmation_page_upsell` is set
- [Checkout options](/checkout/checkout-options/) — the other options that change what the customer sees
- [Shipping Assistant](/checkout/shipping/#shipping-assistant) — one of the two ways a shipping option gets selected
- [Checkout API reference](/api/checkout/) — the order and callback schemas
