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

> ## Agent Instructions
> Laces is event registration software for every kind of event, not only races. Use the event's own wording.
> There is one environment, production: payments made through the API are real. Money is integer minor units; read the event's currency.
> Collecting payments with no Laces event uses POST /payments, then POST /orders/{orderId}/pay: start at /guides/collect-payments. Never call pay to test: there is no sandbox.
> Never put a client secret in browser code or an LLM chat. Branch on error_code, not on message.
> Overview of Laces: https://laces.run/llms.txt

# Collect payments on your own site with Laces

> Take mobile money and card payments on your own site with the Laces API, for products or for events you run yourself. No Laces event, no tickets, one flow.

**Payments only** means your site sells, and Laces collects. You keep your own
pages, your own form and your own records. You send an amount, the buyer pays
by mobile money or card, and the money shows in your organization's Laces
earnings, where you withdraw it.

You never create a Laces event, and no route on this page takes an event id.

Use it for products, courses, memberships, or an **event you run on your own
pages**. If you want Laces to issue tickets and check people in, use a
[Laces event](https://docs.laces.run/guides/custom-ui.md) instead
([Which route do I need?](https://docs.laces.run/index.md#which-route-do-i-need)).

> [!NOTE]
>
> **Every request on this page** goes to `https://connect.laces.run/v1`, from
> your **server**, with `Authorization: Bearer <token>`. Laces must first turn
> on payments for your organization, and your API key needs `payments:write`,
> `orders:write` and `orders:read`. Never send an
> organization id: Laces takes the organization from the token. The client
> secret stays on your server, never in a browser or an LLM chat. **There is
> no sandbox: a pay request moves real money.**

## Before you start

**1. Ask Laces to turn it on**

Payments only is off for every organization until Laces staff switch it
on. Email [support@laces.run](mailto:support@laces.run) with your
organization's name, your website, and what you will sell. Until it is on,
create and quote answer `403 shop_payments_not_enabled`. An organizer or a
developer cannot switch it on. Your organization must also be cleared to
take payments, as for tickets (`403 payments_disabled` when it is not).

**2. Give your API key the permissions**

In the Laces app ([app.laces.run](https://app.laces.run)), an owner or
admin opens **Settings → Developers** and edits the key:

| Scope | Needed for |
| - | - |
| `payments:write` | Create a payment, get a quote |
| `orders:write` | **Also required**: the pay call |
| `orders:read` | **Required for this flow**: every check before you fulfil, retry or release is an order read. It returns buyers' names, emails and phones, so guard the secret. |

Then **fetch a new token** (clear any cached one) and check that its
`scope` lists `payments:write`. A token only carries scopes the key held
when it was issued.

**3. Register your site**

Add your site's origin (for example `https://shop.example.com`) to the
key's **Return URL domains**. `source_url`, `on_success_url` and
`on_failure_url` are refused unless their origin is in that list. You can
also save a default site and default return URLs; see
[API keys](https://docs.laces.run/api-keys.md#settings-for-payments-only).

**4. Add a webhook endpoint**

**Settings → Developers → Webhooks**. It is how you learn that a payment
succeeded. See [Webhooks for payments](https://docs.laces.run/payments/webhooks.md).

## Who does what

* **The buyer pays the Laces fee, on top of your amount.** You send the item
  price; Laces adds the fee and returns the total. Never work out the fee
  yourself, and never put it in your prices: get a [quote](#step-2-show-the-buyer-the-total).
* **You are the seller.** Laces processes the payment. The
  [Laces refund policy](https://laces.run/legal/refund-policy) applies to
  every payment, and the **organizer funds refunds**: the price, not the fee
  ([Refunds](https://docs.laces.run/concepts/fees.md#refunds)). Laces handles the refund: tap
  **Request a refund** on the payment in the Laces app, or email
  [support@laces.run](mailto:support@laces.run) with the order code and the amount.
  The Partner API has no refund route. Where it is sent to a mobile
  money number as a payout, you pay the cost of sending it. If the part of your balance
  that payment went to doesn't cover it, you pay the buyer directly. Some payments
  can't be refunded automatically, so don't promise your buyers an instant refund.
* **Laces does not**: issue a ticket, QR code or badge; keep an attendee list;
  hold stock or places; send reminders; check anyone in; calculate tax or
  shipping; or host a page for your product. All of that is yours.

## Quickstart: your first payment

### Step 1: Get a token

```bash theme={null}
export LACES_BASE="https://connect.laces.run/v1"

TOKEN=$(curl -s -X POST "$LACES_BASE/oauth/token" \
  -u "$LACES_CLIENT_ID:$LACES_CLIENT_SECRET" \
  -d "grant_type=client_credentials" \
  | python3 -c 'import json,sys; print(json.load(sys.stdin)["access_token"])')
```

A token lasts one hour. Cache it; don't fetch one per request.

### Step 2: Show the buyer the total

[`POST /payments/quote`](https://docs.laces.run/api-reference/v1/payments/quote) returns the fee and
total for each payment method. It creates nothing and needs no
`Idempotency-Key`. Limit: about 60 a minute per API client.

```bash theme={null}
curl -s -X POST "$LACES_BASE/payments/quote" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "amount": 50000, "currency": "UGX" }'
```

```json Response 200 theme={null}
{
  "code": 200,
  "message": "Payment quoted successfully",
  "data": {
    "currency": "UGX",
    "price_minor": 50000,
    "laces_fee_minor": 2500,
    "total_minor": 52500,
    "card": { "laces_fee_minor": 4400, "total_minor": 54400 },
    "airtel": { "laces_fee_minor": 3100, "total_minor": 53100 },
    "payment_methods": ["momo", "card", "airtel"]
  }
}
```

| You get | What it is |
| - | - |
| `price_minor` | Your amount, before the fee |
| `laces_fee_minor`, `total_minor` | The fee and total by mobile money (`momo`; in Uganda that is MTN) |
| `airtel`, `card` | The same two figures for those methods. `null`: not available. |
| `payment_methods` | What you may offer. Build your picker from this list. |

Figures here are examples. Rates change and differ per organization, so always
show what the API returns. Amounts are **whole numbers in minor units**: UGX
has no minor unit, so `50000` is UGX 50,000, while `5000` in a USD organization is USD 50.00.

**Next:** show the total for the method the buyer picks.

### Step 3: Create the payment

[`POST /payments`](https://docs.laces.run/api-reference/v1/payments/create). Nothing is charged yet.
Make the `Idempotency-Key` **once per purchase**, save it, and send the same
one on every retry.

```bash theme={null}
curl -s -X POST "$LACES_BASE/payments" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: 6f1c3c9e-2f4b-4c64-9a2f-0d1c5a8b7e11" \
  -H "Content-Type: application/json" \
  -d '{
  "amount": 50000,
  "currency": "UGX",
  "payment_method": "momo",
  "partner_reference": "SHOP-ORDER-8812",
  "description": "Club jersey, size L",
  "product": "jersey",
  "customer": { "name": "Amina Nakato", "email": "amina@example.com", "phone": "+256763494235" },
  "metadata": { "cart_id": "c-8812", "size": "L" },
  "source_url": "https://shop.example.com/jerseys/home",
  "on_success_url": "https://shop.example.com/thanks",
  "on_failure_url": "https://shop.example.com/cart"
}'
```

```json Response 201 theme={null}
{
  "code": 201,
  "message": "Payment created successfully",
  "data": {
    "order": {
      "id": "Pm4xT9cL",
      "order_code": "LC-3N8V5K",
      "order_type": "partner_payment",
      "status": "cart",
      "currency": "UGX",
      "subtotal": 50000,
      "discount_total": 0,
      "donation_total": 0,
      "laces_fee": 2500,
      "total": 52500,
      "failure_kind": null,
      "partner_reference": "SHOP-ORDER-8812",
      "description": "Club jersey, size L",
      "product": "jersey",
      "metadata": { "cart_id": "c-8812", "size": "L" },
      "source_url": "https://shop.example.com/jerseys/home",
      "source_site": "shop.example.com",
      "requested_amount": 50000,
      "requested_currency": "UGX",
      "buyer": { "name": "Amina Nakato", "email": "amina@example.com", "phone": "+256763494235" },
      "attribution": {
        "channel": "partner_api",
        "api_client_id": "LCSCLI-EXAMPLECLNT2345EXAMP",
        "checkout_session_id": null,
        "partner_reference": "SHOP-ORDER-8812"
      },
      "hold_expires_at": "2026-11-25T08:29:03.000Z",
      "prompt_expires_at": null,
      "created_at": "2026-11-25T08:14:03.000Z"
    },
    "checkout_lines": [
      { "label": "Subtotal", "amount": 50000 },
      { "label": "Laces Service Fee", "amount": 2500 },
      { "label": "Total", "amount": 52500 }
    ],
    "is_free": false,
    "is_test_mode": false,
    "fee_rate": { "flat_fee": 500, "percent_fee": 4, "currency": "UGX", "payment_method": "momo" }
  }
}
```

Save `data.order.id` with your purchase **before** you go on. Show
`data.order.total` as the amount due. The answer may also carry
`payment_gateway`; ignore it. A retry with the same key and body answers `200`
with the **original** answer (status `cart`, even if it has been paid since)
and the message "Payment already created (idempotent replay)".

| Field | Required | Rules |
| - | - | - |
| `amount` | Yes | Item price before the fee. A whole number from 1 up, in minor units of your organization's currency. Selling several things? Send one summed amount. Laces may set a highest amount for you; each network also has its own limits, which show up as a failed payment. |
| `currency` | No | Must be your organization's currency if sent |
| `payer_country` | No | Where the buyer pays from. See [Countries and currencies](https://docs.laces.run/payments/countries-and-currencies.md). |
| `payment_method` | No | `momo`, `airtel` or `card`. Sets the fee. Left out: `momo`, or `card` for a US, GB or EU organization. Use only what the quote listed. |
| `partner_reference` | Yes | Your own id, 1 to 128 characters, one line. Laces does not check that it is unique. |
| `description` | Yes | What was bought, 1 to 200 characters, one line. **The buyer sees it** in emails. No web address (`://` or `www.`). |
| `product` | No | A grouping label, up to 80 characters, for example `jersey` or `camp-2026`. Keep it the same for everything you want totalled together. No web address. |
| `customer.name` | Yes | Up to 120 characters. No web address. |
| `customer.email` | Yes | Up to 254 characters. The receipt goes here. |
| `customer.phone` | No | Up to 32 characters. Send it with the country code (`+256…`). US, GB and EU organizations must; elsewhere a local number is read in `payer_country`, else in your organization's country. |
| `metadata` | No | Your own data: up to 20 keys, flat, string values only. Keys 1 to 40 characters of `A-Z a-z 0-9 _ . -`, not starting and ending with `__`; values up to 500; 4096 bytes in total. Returned to you, never shown to the buyer. **No personal or health data, and nothing about children: send an id from your own system.** |
| `source_url` | No | The page on your site the buyer came from. `https`, on a Return URL domain. Emails link to it. Not a link shortener or a shared host. |
| `on_success_url`, `on_failure_url` | No | Where a [card](https://docs.laces.run/payments/card.md) buyer returns. On a Return URL domain. |

### Step 4: Send the buyer to pay

[`POST /orders/{orderId}/pay`](https://docs.laces.run/api-reference/v1/orders/pay), with a **second**
`Idempotency-Key`. For mobile money, send the payer's number:

> [!WARNING]
>
> This moves **real money**. `0763494235` is the example number in these docs.
> Use your own phone, never a made-up number: it belongs to a real person.

```bash theme={null}
curl -s -X POST "$LACES_BASE/orders/Pm4xT9cL/pay" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: 0b1b7d2e-8c3a-4a0e-9f55-3c1d6f2a9b40" \
  -H "Content-Type: application/json" \
  -d '{ "msisdn": "0763494235" }'
```

```json Response 200 theme={null}
{
  "code": 200,
  "message": "Payment initiated successfully",
  "data": {
    "order_id": "Pm4xT9cL",
    "order_code": "LC-3N8V5K",
    "status": "prompt_sent",
    "total": 52500,
    "currency": "UGX",
    "payment_status": "prompt_sent",
    "next_action": { "kind": "await_confirmation", "message": "Approve the payment prompt on your phone" },
    "skipped_provider": false,
    "prompt_expires_at": "2026-11-25T08:18:00.000Z",
    "failure_kind": null,
    "failure_message": null,
    "failure_required_balance": null
  }
}
```

Branch on `data.next_action.kind`:

| `kind` | Do this next |
| - | - |
| `await_confirmation` | Tell the buyer to check their phone and enter their PIN. Go to step 5. |
| `redirect` | Card: send the buyer's browser to `next_action.redirect_url`. See [Card and return URLs](https://docs.laces.run/payments/card.md). |
| `none` | There is nothing for the buyer to do. `payment_status: "failed"`: this attempt did not go through. Anything else: read the order. |

More: [Mobile money](https://docs.laces.run/payments/mobile-money.md).

### Step 5: Wait for proof, then fulfil once

**Proof of payment is a server-side
[`GET /orders/{orderId}`](https://docs.laces.run/api-reference/v1/orders/get) that says
`"status": "paid"` now.** A verified `order.paid` webhook tells you when to look.

A return URL, an email, or anything the browser tells you is **not** proof.

```bash theme={null}
curl -s "$LACES_BASE/orders/Pm4xT9cL" -H "Authorization: Bearer $TOKEN"
```

```json Response 200 theme={null}
{
  "code": 200,
  "message": "Order retrieved successfully",
  "data": {
    "id": "Pm4xT9cL",
    "order_code": "LC-3N8V5K",
    "order_type": "partner_payment",
    "status": "paid",
    "currency": "UGX",
    "subtotal": 50000,
    "discount_total": 0,
    "donation_total": 0,
    "laces_fee": 2500,
    "total": 52500,
    "failure_kind": null,
    "partner_reference": "SHOP-ORDER-8812",
    "description": "Club jersey, size L",
    "product": "jersey",
    "metadata": { "cart_id": "c-8812", "size": "L" },
    "source_url": "https://shop.example.com/jerseys/home",
    "source_site": "shop.example.com",
    "requested_amount": 50000,
    "requested_currency": "UGX",
    "buyer": { "name": "Amina Nakato", "email": "amina@example.com", "phone": "+256763494235" },
    "attribution": {
      "channel": "partner_api",
      "api_client_id": "LCSCLI-EXAMPLECLNT2345EXAMP",
      "checkout_session_id": null,
      "partner_reference": "SHOP-ORDER-8812"
    },
    "hold_expires_at": null,
    "prompt_expires_at": null,
    "created_at": "2026-11-25T08:14:03.000Z"
  }
}
```

Check that `requested_amount` and `requested_currency` are what you asked for,
that the order is yours (`partner_reference`), that `status` is `paid` **now**,
then fulfil **once**.
`total` can differ from your quote, because a card buyer can change how they
pay on the Laces page.

| `status` | Meaning | Do this next |
| - | - | - |
| `cart` | Created, or the buyer is on the card page | Wait |
| `payment_initiated`, `prompt_sent` | The buyer is being asked to pay. Usually minutes, at most about 2 hours. | Wait. Never call pay. |
| `paid` | Paid | Fulfil once |
| `failed`, `expired` | Not paid. An unpaid `cart` becomes `expired` 15 to 20 minutes after creation. A late payment can still turn either into `paid`. | Offer to try again |
| `cancelled` | Closed. Laces does not set it on payments today. | Create a new payment if the buyer still wants it |
| `refunded`, `partially_refunded` | All, or part, of the [price](https://docs.laces.run/concepts/fees.md#refunds) was returned. The amount is only in the `order.refunded` webhook. | Undo or adjust by the amount |
| `chargeback_flagged` | Reserved for disputes. No webhook. | Review by hand |

**No webhook is sent when a buyer simply walks away.** Read the order if you
need to know, for example before you release something you were keeping for
them.

## The whole thing in Node

```js laces.js theme={null}
// Node 18+. Server only: it uses the client secret.
const BASE = process.env.LACES_BASE ?? "https://connect.laces.run/v1";
const TIMEOUT_MS = 60_000; // a pay call can take a while

let cached = { token: null, exp: 0 };
async function getToken(signal) {
  if (cached.token && Date.now() < cached.exp - 60_000) return cached.token;
  const basic = Buffer.from(
    `${process.env.LACES_CLIENT_ID}:${process.env.LACES_CLIENT_SECRET}`,
  ).toString("base64");
  const res = await fetch(`${BASE}/oauth/token`, {
    method: "POST",
    headers: {
      Authorization: `Basic ${basic}`,
      "Content-Type": "application/x-www-form-urlencoded",
    },
    body: "grant_type=client_credentials",
    signal,
  });
  const body = await res.json();
  if (!res.ok) throw new Error(`token: ${body.error}`);
  cached = { token: body.access_token, exp: Date.now() + body.expires_in * 1000 };
  return cached.token;
}

export async function laces(method, path, { body, idempotencyKey, timeoutMs = TIMEOUT_MS } = {}) {
  const signal = AbortSignal.timeout(timeoutMs); // the whole call, token included
  for (let refreshed = false; ; refreshed = true) {
    const res = await fetch(`${BASE}${path}`, {
      method,
      headers: {
        Authorization: `Bearer ${await getToken(signal)}`,
        ...(body && { "Content-Type": "application/json" }),
        ...(idempotencyKey && { "Idempotency-Key": idempotencyKey }),
      },
      ...(body && { body: JSON.stringify(body) }),
      signal,
    });
    const json = await res.json().catch(() => ({}));
    if (res.ok) return json.data;
    if (json.error_code === "invalid_token" && !refreshed) {
      cached = { token: null, exp: 0 }; // once: the token was refused before any work
      continue;
    }
    const err = new Error(json.error_code ?? `http_${res.status}`);
    err.status = res.status;
    err.code = json.error_code ?? null; // stable: branch on this
    err.details = json.details ?? null;
    err.retryAfter = Number(res.headers.get("Retry-After")) || null;
    err.requestId = res.headers.get("X-Request-Id"); // quote this to support
    throw err;
  }
}
```

One file. Two functions: `retryPayment` picks or creates an order and gives you
the total to show, `pay` charges it.

```js checkout.js theme={null}
import crypto from "node:crypto";
import { laces } from "./laces.js";
import { db } from "./db.js"; // your own store

const TRY_AGAIN = ["cart", "failed", "expired", "cancelled"]; // anything else stops
const LIVE = ["payment_initiated", "prompt_sent"];

// Still what the buyer is being sold? If not, it needs a new order.
const sameTerms = (attempt, purchase) =>
  attempt.body.amount === purchase.amount &&
  attempt.body.currency === purchase.currency &&
  attempt.body.payer_country === purchase.payerCountry;

function stopFor(order, attempt) {
  if (order.status === "paid") return "paid";
  if (LIVE.includes(order.status)) return "wait";
  if (!TRY_AGAIN.includes(order.status)) return "review"; // refunded, disputed, new
  // A pay call with no answer may still be running: for 3 minutes any of
  // those statuses, an earlier `failed` too, says nothing about it.
  if (Date.now() - (attempt.unansweredAt ?? 0) < 3 * 60_000) return "wait";
  return null;
}

// The state of a purchase, from EVERY order it ever had. Anything not known to
// be safe stops. Both functions below call it, inside the lock.
async function look(purchaseId) {
  const { fulfilled, undone, released } = await db.stateOf(purchaseId);
  if (undone) return { stop: "review" };
  if (fulfilled) return { stop: "paid" };

  // Orders of a Laces event, if you moved from them: only a reason to stop.
  for (const old of await db.ticketOrdersOf(purchaseId)) {
    const order = await laces("GET", `/orders/${old.orderId}`, { timeoutMs: 6000 });
    const stop = order.status === "cart" ? "wait" : stopFor(order, old); // a cart soon expires
    if (stop) return { stop };
  }
  const attempts = await db.attemptsOf(purchaseId); // payments, oldest first
  let order = null;
  for (const attempt of attempts) {
    order = null;
    if (!attempt.orderId) continue; // pay was never called on it
    order = await laces("GET", `/orders/${attempt.orderId}`, { timeoutMs: 6000 });
    const stop = stopFor(order, attempt);
    if (stop) return { stop };
  }
  if (released) return { stop: "released" }; // its stock or places are gone
  return { latest: attempts.at(-1) ?? null, order };
}

// The buyer chose how to pay: the first time, again, or with another method or
// phone. The ONLY way to get an attempt. Charges nothing.
// purchase: { id, reference, amount, currency, payerCountry?, ... }, your price before the fee.
export function retryPayment(purchase, { method, phone }) {
  return db.withLock(purchase.id, async () => {
    const { stop, latest, order } = await look(purchase.id);
    if (stop) return { step: stop };

    const young = order && Date.now() - Date.parse(order.created_at) < 15 * 60_000;
    if (latest && !latest.closed && latest.method === method && sameTerms(latest, purchase)) {
      if (!latest.orderId && latest.phone === phone) return create(latest); // same key again
      if (young && ["cart", "failed"].includes(order.status)) {
        latest.phone = phone;
        latest.payKey = crypto.randomUUID(); // a new try needs a new key
        latest.ready = true;
        await db.saveAttempt(latest);
        return { step: "confirm_total", attempt: latest, total: order.total, currency: order.currency };
      }
    }
    const attempt = {
      purchaseId: purchase.id, method, phone, orderId: null,
      createKey: crypto.randomUUID(), payKey: crypto.randomUUID(),
      body: {
        amount: purchase.amount,
        currency: purchase.currency,
        ...(purchase.payerCountry && { payer_country: purchase.payerCountry }),
        payment_method: method, // from the quote's payment_methods
        partner_reference: purchase.reference,
        description: purchase.description,
        product: purchase.product,
        customer: { name: purchase.name, email: purchase.email, phone },
        metadata: { cart_id: purchase.cartId },
        source_url: "https://shop.example.com/jerseys/home",
        on_success_url: "https://shop.example.com/thanks",
        on_failure_url: "https://shop.example.com/cart",
      },
    };
    await db.saveAttempt(attempt); // keys and body, BEFORE the call
    return create(attempt);
  });
}

// Safe to repeat after a timeout or a 5xx: same key, same body.
async function create(attempt) {
  const { order } = await laces("POST", "/payments", {
    idempotencyKey: attempt.createKey,
    body: attempt.body,
  }).catch(async (err) => {
    const temporary = ["idempotency_in_progress", "rate_limited"].includes(err.code);
    if (err.status >= 400 && err.status < 500 && !temporary) {
      attempt.closed = true; // refused: corrected details get a new key
      await db.saveAttempt(attempt);
    }
    throw err;
  });
  attempt.orderId = order.id;
  attempt.ready = true;
  await db.saveAttempt(attempt);
  return { step: "confirm_total", attempt, total: order.total, currency: order.currency };
}

// The buyer saw that total and pressed Pay: once per retryPayment. After any
// failure, go through retryPayment again. Never call this from a job or a loop.
export function pay(purchase, attempt) {
  return db.withLock(purchase.id, async () => {
    const { stop, latest } = await look(purchase.id);
    if (stop) return { step: stop };
    const usable =
      latest?.orderId === attempt.orderId && latest.ready && !latest.closed && sameTerms(latest, purchase);
    if (!usable) return { step: "start_again" };

    latest.ready = false;
    // Card: opening the page charges nothing, so it is never "unanswered".
    latest.unansweredAt = latest.method === "card" ? null : Date.now();
    await db.saveAttempt(latest);
    const answered = async (fields = {}) => {
      Object.assign(latest, { unansweredAt: null }, fields);
      await db.saveAttempt(latest);
    };
    try {
      const { next_action } = await laces("POST", `/orders/${latest.orderId}/pay`, {
        idempotencyKey: latest.payKey,
        body: latest.method === "card" ? {} : { msisdn: latest.phone },
      });
      await answered();
      return { step: "next", next: next_action };
    } catch (err) {
      if (["hold_expired", "reprice_required", "rate_lock_expired"].includes(err.code)) {
        await answered({ closed: true }); // nothing charged; a new order is needed
        return { step: "start_again", code: err.code };
      }
      const waiting = ["prompt_in_progress", "charge_pending_same_number", "idempotency_in_progress"];
      if (waiting.includes(err.code)) return { step: "wait" };
      if (err.status >= 400 && err.status < 500) await answered(); // refused
      throw err; // no answer or 5xx: stays unanswered for 3 minutes
    }
  });
}
```

| `step` | Show the buyer |
| - | - |
| `confirm_total` | `total`, and a Pay button that calls `pay` |
| `next` | Act on `next.kind` (step 4) |
| `wait` | "We're waiting for your payment" |
| `paid` | Done: your webhook handler fulfils |
| `start_again` | Choose how to pay again: call `retryPayment` (on `reprice_required` in Uganda, with the number's own network) |
| `released` | Your reservation has ended. To buy again, make a **new** purchase that takes stock or places again |
| `review` | "We're checking your payment": a person looks |

Your `db` here: `saveAttempt`, `attemptsOf(purchaseId)` (oldest first),
`ticketOrdersOf(purchaseId)` (`[]` if you never sold event tickets),
`stateOf(purchaseId)` (`{ fulfilled, undone, released }`, read now, see
[Webhooks](https://docs.laces.run/payments/webhooks.md#a-complete-handler-node-express)) and `withLock(purchaseId, fn)`, which runs one `fn` at a time for a purchase on
**all** your servers, so a double click can't pay twice. The lock must outlive
the 60 s pay timeout plus the reads: give it **5 minutes**, released when `fn`
ends.

The webhook handler is on [Webhooks for payments](https://docs.laces.run/payments/webhooks.md).

## Example 1: a product

The quickstart above is this example: one jersey, `product: "jersey"`, your
cart id in `metadata`, the product page in `source_url`.

## Example 2: an event on your own site

You run the registration form. Laces only collects. One family registers one
adult and two children at UGX 75,000 each, and pays **once**.

1. **Save the registration on your side first**, with the names, guardians and
   consent. Laces never sees them. Keep the places for the buyer: Laces cannot
   hold them.

2. **Quote the sum**: `3 × 75000 = 225000`. Part of the fee is per payment,
   so never multiply a one-place total.

   ```bash theme={null}
   curl -s -X POST "$LACES_BASE/payments/quote" \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{ "amount": 225000, "currency": "UGX" }'
   ```

   ```json Response 200 theme={null}
   {
     "code": 200,
     "message": "Payment quoted successfully",
     "data": {
       "currency": "UGX",
       "price_minor": 225000,
       "laces_fee_minor": 9500,
       "total_minor": 234500,
       "card": { "laces_fee_minor": 14550, "total_minor": 239550 },
       "airtel": { "laces_fee_minor": 11850, "total_minor": 236850 },
       "payment_methods": ["momo", "card", "airtel"]
     }
   }
   ```

3. **Create the payment.** `product` is the event: the same value for every
   payment for that event, so the app totals them together. `metadata` carries
   **an id from your system**, never attendee details.

   ```bash theme={null}
   curl -s -X POST "$LACES_BASE/payments" \
     -H "Authorization: Bearer $TOKEN" \
     -H "Idempotency-Key: 8e2f6b10-53d1-4c0e-9d7b-6a1f0c4e2b97" \
     -H "Content-Type: application/json" \
     -d '{
       "amount": 225000,
       "currency": "UGX",
       "payment_method": "momo",
       "partner_reference": "REG-20417",
       "description": "Camp 2026: 1 adult and 2 children",
       "product": "camp-2026",
       "customer": { "name": "Amina Nakato", "email": "amina@example.com", "phone": "+256763494235" },
       "metadata": { "registration_id": "reg-20417", "adults": "1", "children": "2" },
       "source_url": "https://camp.example.org/register"
     }'
   ```

   ```json Response 201 theme={null}
   {
     "code": 201,
     "message": "Payment created successfully",
     "data": {
       "order": {
         "id": "Zs5kF8nA",
         "order_code": "LC-4T7X2M",
         "order_type": "partner_payment",
         "status": "cart",
         "currency": "UGX",
         "subtotal": 225000,
         "discount_total": 0,
         "donation_total": 0,
         "laces_fee": 9500,
         "total": 234500,
         "failure_kind": null,
         "partner_reference": "REG-20417",
         "description": "Camp 2026: 1 adult and 2 children",
         "product": "camp-2026",
         "metadata": { "registration_id": "reg-20417", "adults": "1", "children": "2" },
         "source_url": "https://camp.example.org/register",
         "source_site": "camp.example.org",
         "requested_amount": 225000,
         "requested_currency": "UGX",
         "buyer": { "name": "Amina Nakato", "email": "amina@example.com", "phone": "+256763494235" },
         "attribution": {
           "channel": "partner_api",
           "api_client_id": "LCSCLI-EXAMPLECLNT2345EXAMP",
           "checkout_session_id": null,
           "partner_reference": "REG-20417"
         },
         "hold_expires_at": "2026-11-25T08:29:03.000Z",
         "prompt_expires_at": null,
         "created_at": "2026-11-25T08:14:03.000Z"
       },
       "checkout_lines": [
         { "label": "Subtotal", "amount": 225000 },
         { "label": "Laces Service Fee", "amount": 9500 },
         { "label": "Total", "amount": 234500 }
       ],
       "is_free": false,
       "is_test_mode": false,
       "fee_rate": { "flat_fee": 500, "percent_fee": 4, "currency": "UGX", "payment_method": "momo" }
     }
   }
   ```

4. **Pay** with `POST /orders/Zs5kF8nA/pay`, as in step 4 above.

5. **Fulfil on `order.paid`**: confirm the registration, send your own ticket
   or badge. When your own deadline passes, read the order: release the places
   if it is `failed` or `expired`, wait if it is live. `order.failed` alone is
   not enough, the buyer may be retrying. If a late `order.paid` arrives after
   that, rebook, or ask Laces to refund it.

The webhook for this payment:

```json order.paid theme={null}
{
  "id": "LCSWHD-3D81B6F0C9A7425E8F10D2C4B7A95E63",
  "type": "order.paid",
  "created": 1795594530,
  "attribution": {
    "channel": "partner_api",
    "api_client_id": "LCSCLI-EXAMPLECLNT2345EXAMP",
    "checkout_session_id": null,
    "partner_reference": "REG-20417"
  },
  "data": {
    "order": {
      "id": "Zs5kF8nA",
      "order_code": "LC-4T7X2M",
      "order_type": "partner_payment",
      "status": "paid",
      "currency": "UGX",
      "subtotal": 225000,
      "discount_total": 0,
      "donation_total": 0,
      "laces_fee": 9500,
      "total": 234500,
      "failure_kind": null,
      "partner_reference": "REG-20417",
      "description": "Camp 2026: 1 adult and 2 children",
      "product": "camp-2026",
      "metadata": { "registration_id": "reg-20417", "adults": "1", "children": "2" },
      "source_url": "https://camp.example.org/register",
      "source_site": "camp.example.org",
      "requested_amount": 225000,
      "requested_currency": "UGX",
      "attribution": {
        "channel": "partner_api",
        "api_client_id": "LCSCLI-EXAMPLECLNT2345EXAMP",
        "checkout_session_id": null,
        "partner_reference": "REG-20417"
      },
      "hold_expires_at": null,
      "prompt_expires_at": null,
      "created_at": "2026-11-25T08:14:03.000Z"
    }
  }
}
```

## What the buyer receives from Laces

| Email | When |
| - | - |
| **Receipt** | Once, when the payment succeeds. It names your organization, your site, the `description`, the total, the order code and your `partner_reference`, gives your organization's support contact if it has one, and links to your page and to the refund policy. |
| **Payment didn't go through** | At most once per payment, when it definitely failed, and only if there is a page to link to (`source_url`, or the key's default site). "Try again" goes to **your** page. Not guaranteed. |
| **Refund confirmation** | Normally, when a refund of the order's price is recorded as completed, whether Laces sends it or your organization is to pay the buyer directly. In the second case the email says so; it is not proof of payment. |

Nothing else: no reminders, no abandoned-cart email, no ticket. No email sends
a buyer to a Laces payment page. Send your own order confirmation.

## Testing

There is no sandbox, and `is_test_mode` is always `false`. Quotes and creating
a payment move no money, so test those freely. **The pay call moves real
money**: make one small payment from your own phone, check the webhook, then
stop. See [Going live](https://docs.laces.run/payments/going-live.md).

## Moving from event orders

Already selling through `POST /orders` and an event on Laces? Your token, pay
call, polling and webhook endpoint stay. You swap `POST /orders` for
`POST /payments` and stop needing an event id. Old orders stay where they are
and need no migration. Full steps, payloads and a prompt for your LLM:
[Move from event orders](https://docs.laces.run/payments/move-from-event-orders.md).

## Next

> [card] [Mobile money](https://docs.laces.run/payments/mobile-money.md)
>
> Prompts, retries and limits.

> [card] [Card and return URLs](https://docs.laces.run/payments/card.md)
>
> The hosted page and the way back.

> [card] [Countries and currencies](https://docs.laces.run/payments/countries-and-currencies.md)
>
> Buyers in another country.

> [card] [Webhooks](https://docs.laces.run/payments/webhooks.md)
>
> Verify, fulfil once, reconcile.

> [card] [Errors](https://docs.laces.run/payments/errors.md)
>
> Every code and what to do.

> [card] [Going live](https://docs.laces.run/payments/going-live.md)
>
> The launch checklist.


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