> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ignyt.si/llms.txt
> Use this file to discover all available pages before exploring further.

# Build your checkout

> Quote, get the shopper's approval, submit once, take payment and track each store's order.

Checkout
One shopper purchase can include products from several stores. Ignyt takes one payment and places one order with each store.

## The checkout flow

```mermaid theme={"theme":{"light":"github-light","dark":"vesper"}}
sequenceDiagram
    participant Shopper
    participant App as Your app (server)
    participant Ignyt
    participant Pay as Payment page
    participant Store as Merchant stores
    App->>Ignyt: Create cart, add lines, set address
    App->>Ignyt: POST /quotes
    Ignyt->>Store: Ask each store for price, shipping and tax
    Ignyt-->>App: Quote with one total
    App->>Shopper: Show the exact total
    Shopper-->>App: Approve
    App->>Ignyt: POST /submit (Idempotency-Key)
    Ignyt-->>App: 202 Accepted (purchase_id)
    App->>Ignyt: GET /carts/{id}/purchase
    Ignyt-->>App: payment_action.url
    App->>Shopper: Embed or open the payment form
    Shopper->>Pay: Pay
    Ignyt->>Store: Place one order per store
    Ignyt-->>App: Webhooks: payment, purchase, store orders
```

The [quickstart](https://docs.ignyt.si/quickstart.md) runs this flow with real requests. This page explains how to handle the cases a real checkout meets.

## 1. Get a quote

After adding lines and a delivery address, request a quote with `POST /v1/carts/{cart_id}/quotes`. Ignyt asks every store in the cart for current prices, stock, shipping and tax, and returns one total that is valid until `expires_at`.

Before showing the total, check the quote:

* **`unsupported` lines:** items that can't be bought right now, for example because they sold out. Tell the shopper.
* **`coupon_results`:** every [supplied coupon](https://docs.ignyt.si/discounts.md) must be verified for its merchant basket. A rejected or unverifiable code blocks the entire cart before payment. Correct the cart and request a fresh quote.
* **Price changes:** if stock or prices changed since the shopper added items, the quote request fails with `409 cart_requires_review` and `details.changes` lists what changed. Show the changes, accept them with `POST /v1/carts/{cart_id}/accept-review`, and request a new quote.

Amounts are integer minor units in the quote's `currency`: `27720` with `AED` is AED 277.20.

## 2. Get the shopper's approval

Show the shopper the quote's `total_minor` and get an explicit approval of that amount. If anything in the cart changes after the quote, the quote is no longer valid; request a new one and ask again. Never quietly accept a higher total for the shopper.

## 3. Submit once

Submit with the approved quote and total. Create an `Idempotency-Key` for this checkout, save it with the cart, and send it with the request.

```bash theme={"theme":{"light":"github-light","dark":"vesper"}}
curl -X POST "$IGNITE_API_BASE_URL/v1/carts/$CART_ID/submit" \
  -H "Authorization: Bearer $IGNITE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: checkout-$CART_ID-1" \
  -d '{"quote_id": "'"$QUOTE_ID"'", "approved_total_minor": 27720,
       "partial_order_policy": "allow_partial",
       "shopper_contact": {"email": "shopper@example.com"}}'
```

| Field | Notes |
| - | - |
| `quote_id` | The active quote the shopper approved. |
| `approved_total_minor` | Must equal the quote's `total_minor` exactly, or you get `409 approval_mismatch`. |
| `partial_order_policy` | Recommended: `allow_partial`. If one store fails, the others still go ahead and the failed share is refunded. |
| `shopper_contact` | Optional contact details, such as `email` and `phone`, passed to the stores for fulfilment and order emails. Include an email: without one, the shopper can't use the embedded payment form and gets the provider's full payment page instead. |

A `202` response with `purchase_id` means Ignyt accepted the purchase and will process it. It doesn't mean the payment succeeded yet.

If you don't get a response, send the **same key and body** again. You get the original result back with `"duplicate": true`; Ignyt never creates a second purchase. Reusing the key with a different body returns `409 conflict`.

## 4. Take the payment

Read `GET /v1/carts/{cart_id}/purchase` after submission. While checkout starts, it can return purchase
status `accepted`, payment status `pending`, and no merchant orders or payment action. Keep the
original cart and retry the read with backoff.

When `payment.status` is `requires_action` and a payment action is available, use its `presentation`:

* `embed` loads Mamo's payment form in an iframe on your HTTPS checkout. Ignyt enables it per configured
  Sandbox app and uses the submitted shopper email to prefill the form.
* `redirect`, or an absent `presentation` on an older API, opens the provider-hosted page.

Both use `payment_action.url` and retain the existing `type: "redirect"` for compatibility. Register
your app's HTTPS return page with Ignyt before enabling inline checkout. After capture, Mamo can
navigate the full page to that return URL. A bank challenge can also require full-page navigation.
When the shopper returns or reopens checkout, read the original cart purchase again. Display payment
confirmation from Ignyt's verified payment state and show each store's order progress separately.

Use the [checkout SDK](https://docs.ignyt.si/typescript-sdk.md#branded-web-and-mobile-checkout) to embed the form in a web checkout and resume the same
purchase on iOS and Android.

A missing action can also mean payment is in progress. Continue reading the original checkout. This
API does not offer shopper cancellation for a submitted unpaid Mamo payment. Quote expiry governs
submission and does not establish that an already issued Mamo payment link is closed.

## 5. Track each store's order

A purchase has a status, and each store order inside it has its own.

| Purchase status | Meaning |
| - | - |
| `received` | Ignyt accepted the submission. |
| `paying` | Waiting for the shopper's payment. |
| `placing` | Payment succeeded; Ignyt is placing the store orders. |
| `placed` | Every store order was placed. |
| `partially_placed` | Some store orders were placed and others failed or were cancelled. The failed share is refunded. |
| `failed` / `cancelled` | No store order was placed. |
| `completed` | Every store order was delivered. |

Read store orders from `merchant_orders` in `GET /v1/purchases/{purchase_id}`, or subscribe to the `order.purchase.updated`, `order.merchant_order.updated` and `money.payment.updated` [events](https://docs.ignyt.si/event-types.md). Show each store's status separately in your app.

## Lost responses and timeouts

A timeout or `5xx` after a write does not mean it failed. The purchase or payment may have gone through.

* Read the original cart or purchase before doing anything else.
* If the operation takes an `Idempotency-Key`, retry with the original key and body.
* Never create a new cart, purchase or payment to replace one whose result you don't know.

A store order can stay `unknown` while Ignyt checks with the store. Show it as pending; Ignyt resolves it by looking the order up, never by placing it again. See [Errors and retries](https://docs.ignyt.si/errors-and-retries.md).

## Related guides

> [card] [Refunds, returns and cancellations](https://docs.ignyt.si/refunds-and-returns.md)
>
> What to do after checkout.

> [card] [Discounts and promotions](https://docs.ignyt.si/discounts.md)
>
> Apply store coupons before quoting.

> [card] [Test in Sandbox](https://docs.ignyt.si/sandbox-testing.md)
>
> Trigger price changes, sold-out items and failed orders.

> [card] [Error codes](https://docs.ignyt.si/error-codes.md)
>
> Checkout error codes and what to do.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.