> ## 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

# Move from event orders to payments only on Laces

> Switch your own registration site from POST /orders on a Laces event to POST /payments: before and after requests, every payload, a checklist and an LLM prompt.

For a site that already sells through the Laces API with `POST /orders` and a
Laces event, and runs its own registration form. After the move, Laces only
collects.

> [!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.**

> [!WARNING]
>
> Never paste the client secret, the webhook secret or an access token into an
> LLM chat, a browser or a public repository. Use placeholders. **The first pay
> request after the change moves real money**: a person makes that payment, not
> a tool, and only once.

## What changes, and what stays

| | Before | After |
| - | - | - |
| Create | `POST /orders` | `POST /payments` |
| Prices to show | `GET /events/{eventId}` | `POST /payments/quote` |
| Pay | `POST /orders/{orderId}/pay` | **The same** |
| Read and list | `GET /orders/{orderId}`, `GET /orders` | **The same** |
| Webhook endpoint, signature, secret | | **The same** |
| Token endpoint, host, idempotency rules | | **The same** |
| Scopes | `orders:write` | `orders:write`, `payments:write` **and** `orders:read` |
| `event_id`, ticket types, waiver, `custom_fields`, discounts, donations | Laces | **Yours** |
| Tickets, QR codes, participant list, check-in, reminders | Laces | **Yours**. No new ones on Laces. |
| Money, withdrawals | Laces earnings | The same balance, shown under Payments |

**Nothing is migrated.** Old orders, refunds and earnings stay on the Laces
event. New ones are payments. Both count in the same organization balance.

## Step 1: Make the webhook handler accept both, and deploy it

Do this first: the moment payments are turned on, your endpoints and
`orders:read` keys can see payment orders. **In this order:**

1. Pause your deadline job (the one that gives places back).
2. Add `fulfilled`, `undone` and `released` to registrations, and run the
   [backfill](#backfill): the confirmed ones, then those whose places the old
   code gave back.
3. Deploy the handler below. Keep the delivery ids you have saved, so an event
   the old code handled is skipped.
4. Run the backfill again, for what the old code confirmed in between.
5. Restart the deadline job, as `releaseIfOver`. Then [step 2](#step-2-switch-it-on).

Payments have **no `event_id`** (at the top or on the order), **no
`ticket_count`** and **no `registrations`**. Ticket orders have **no
`order_type`, `requested_amount` or `requested_currency`**: keep your own check
on `total` for those.

Add this **above** your existing ticket code:

```js theme={null}
const order = event.data?.order;
if (order?.order_type === "partner_payment") {          // absent on ticket orders
  if (order.attribution.api_client_id !== process.env.LACES_CLIENT_ID) return; // another key's
  const registration =
    (await db.findByLacesOrderId(order.id)) ?? (await db.findByReference(order.partner_reference));
  if (!registration) return db.saveForReview(null, order, "unknown payment");
  if (event.type === "order.refunded") {
    return refundPayment(registration, order, event.data.refund);
  }
  if (event.type === "order.paid") return fulfilIfPaid(registration, order.id);
  return;                                               // order.failed: release nothing here
}
// Ticket orders: the same shared state as payments.
if (order && ["order.paid", "order.refunded"].includes(event.type)) {
  let registration = await db.findByTicketOrderId(order.id); // any key
  if (!registration) { // an id you did not save: the reference counts only under our key
    const ours = order.attribution.api_client_id === process.env.LACES_CLIENT_ID;
    const sameReference = await db.findByReference(order.attribution.partner_reference); // null finds nothing
    if (ours && sameReference) {
      registration = sameReference;
      await db.saveTicketOrder(registration.id, order.id);
    } else if (ours || sameReference) {
      return db.saveForReview(null, order, "unknown ticket order"); // attached to nothing
    }
  }
  if (registration && event.type === "order.paid") return ticketPaid(registration, order.id);
  if (registration) return refundPayment(registration, order, event.data.refund);
}
// ...the rest of your ticket order code, which must not fulfil or undo by itself
```

`ticketPaid` is in `cutover.js`, in [step 4](#step-4-create-a-payment-instead-of-an-order). In
`webhook.js` the ticket part is the body of `handleTicketOrder`.

Skip events of another key **only for payments**: a ticket order can carry
another client id, or `null`, and is still yours if you saved its id. Make sure your ticket code ignores anything it
doesn't know.

`fulfilIfPaid` reads the order, requires `status: "paid"` now, and compares
reference, amount and currency. `refundPayment` undoes once the price is back.
Both, and the whole handler, are on
[Webhooks](https://docs.laces.run/payments/webhooks.md#a-complete-handler-node-express). `refundPayment`
takes ticket orders too.

### Backfill

For every registration your old code confirmed, with the ticket order that
confirmed it. Without it your deadline job could give a confirmed
registration's places back, and a payment could be fulfilled on top of it
without "paid twice". Safe to run again.

```js backfill.js theme={null}
import { laces } from "./laces.js";
import { db } from "./db.js"; // your own store

export async function backfill(registration, ticketOrderId) {
  const order = await laces("GET", `/orders/${ticketOrderId}`);
  // `undone` too if you already cancelled it and gave its places back.
  await db.adopt(registration.id, order.id, { undone: registration.cancelled });
  if ((await db.stateOf(registration.id)).undone) return;
  if (["refunded", "partially_refunded"].includes(order.status) || (await db.priceIsBack(order))) {
    // Never undone in bulk: a person decides, with db.undo.
    await db.saveForReview(registration.id, order, `${order.status} before the move`);
  }
}

// For every registration whose places the old code gave back. Otherwise the
// restarted job gives them back twice, and a late payment fulfils a gone place.
export async function backfillReleased(registration) {
  await db.markReleased(registration.id); // sets `released` if `fulfilled` is empty, gives nothing back
}
```

## Step 2: Switch it on

1. Ask [support@laces.run](mailto:support@laces.run) to turn payments on for
   your organization.
2. An owner or admin adds `payments:write` and `orders:read` to your API key, and your site to
   its **Return URL domains**.
3. **Get a new token**, clear any cached one, and check its `scope`.

## Step 3: Quote instead of reading the event

```diff theme={null}
- GET /v1/events/q3Zk9mVx
+ POST /v1/payments/quote
+ { "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"]
  }
}
```

`amount` is the **item price for everything in this payment, before the fee**.
If your page shows all-in prices that already contain the Laces fee, take the
fee out, or the buyer pays it twice. Part of the fee is per payment, so quote
the whole sum, and quote again for each method.

## Step 4: Create a payment instead of an order

Before:

```json POST /v1/orders theme={null}
{
  "event_id": "q3Zk9mVx",
  "lines": [
    { "ticket_type_id": "tt_adult", "quantity": 1 },
    { "ticket_type_id": "tt_child", "quantity": 2 }
  ],
  "buyer_name": "Amina Nakato",
  "buyer_email": "amina@example.com",
  "buyer_phone": "0763494235",
  "payment_method": "momo",
  "waiver_accepted": true,
  "waiver_version": "2026-09-01",
  "custom_fields": { "emergency_contact": "On file" },
  "partner_reference": "REG-20417"
}
```

After (same headers: `Authorization`, `Idempotency-Key`, `Content-Type`):

```json POST /v1/payments theme={null}
{
  "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"
}
```

| Before | After |
| - | - |
| `event_id` | Not sent. `product` is your label for the event: the same value every time. |
| `lines`, `quantity` | One summed `amount`. Keep the breakdown on your side. |
| `buyer_name`, `buyer_email` | `customer.name`, `customer.email` |
| `buyer_phone` (required) | `customer.phone` (optional; send the country code) |
| `payment_method` | The same: `momo`, `airtel`, `card` |
| `partner_reference` (optional) | The same, **required** |
| `waiver_accepted`, `waiver_version` | Not sent. Collect and keep consent yourself. |
| `custom_fields`, participants | Not sent. Keep them yourself; put an id in `metadata`. |
| `discount_code`, `donation_amount` | Not sent. Work them into `amount`. |
| None | `description` (**required**, the buyer sees it), `source_url`, `on_success_url`, `on_failure_url` |

```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" }
  }
}
```

**A registration that already has a ticket order:** `retryPayment` and `pay` read
its ticket orders (`db.ticketOrdersOf`, `{ orderId, unansweredAt? }`) every time
and stop if one is paid or could be. Stop calling pay on ticket orders from now
on.

```js cutover.js theme={null}
import { laces } from "./laces.js";
import { db } from "./db.js"; // your own store
import { fulfil } from "./webhook.js"; // on Webhooks

// Step 1 calls it on order.paid, and releaseIfOver reaches it through that code.
export async function ticketPaid(registration, orderId) {
  const { fulfilled } = await db.stateOf(registration.id);
  if (fulfilled === orderId) return;
  const order = await laces("GET", `/orders/${orderId}`, { timeoutMs: 6000 });
  if (order.status === "partially_refunded" && !fulfilled) {
    return db.saveForReview(registration.id, order, "part refunded before we fulfilled");
  }
  if (order.status !== "paid") return; // refunded meanwhile, or not paid yet
  if (order.total !== registration.ticketTotal) { // your own check
    return db.saveForReview(registration.id, order, "not what we asked for");
  }
  await fulfil(registration, order); // shared with payments
}
```

A **card page still open** can pay a `failed` or `expired` ticket order at any
time, even on a closed event, also just after `pay` read it. Nothing cancels it:
that is what the shared
`fulfil` and the review are for. Ask the buyer to close it.

A retry with the same key answers `200` with the same `data` and the message
"Payment already created (idempotent replay)". In the answer, `registrations`,
`event_name`, `event_when_label` and `poster_theme` are gone, and
`order.event_id` is replaced by `order.order_type`.

## Step 5: Pay, unchanged

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

(`0763494235` is the example number in these docs; use the payer's own.)

```json Response 200: prompt sent, wait theme={null}
{
  "code": 200,
  "message": "Payment initiated successfully",
  "data": {
    "order_id": "Zs5kF8nA",
    "order_code": "LC-4T7X2M",
    "status": "prompt_sent",
    "total": 234500,
    "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
  }
}
```

```json Response 200: nothing sent, safe to try again theme={null}
{
  "code": 200,
  "message": "Payment initiated successfully",
  "data": {
    "order_id": "Zs5kF8nA",
    "order_code": "LC-4T7X2M",
    "status": "failed",
    "total": 234500,
    "currency": "UGX",
    "payment_status": "failed",
    "next_action": { "kind": "none" },
    "skipped_provider": false,
    "prompt_expires_at": null,
    "retry_safe": true,
    "failure_kind": "provider_not_reached",
    "failure_message": null,
    "failure_required_balance": null
  }
}
```

For **card**, create with `payment_method: "card"` and pay with `{}`:

```json POST /v1/payments theme={null}
{
  "amount": 225000,
  "currency": "UGX",
  "payment_method": "card",
  "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",
  "on_success_url": "https://camp.example.org/done",
  "on_failure_url": "https://camp.example.org/register"
}
```

```json Response 201 theme={null}
{
  "code": 201,
  "message": "Payment created successfully",
  "data": {
    "order": {
      "id": "Wn2dG6jR",
      "order_code": "LC-5B9K3T",
      "order_type": "partner_payment",
      "status": "cart",
      "currency": "UGX",
      "subtotal": 225000,
      "discount_total": 0,
      "donation_total": 0,
      "laces_fee": 14550,
      "total": 239550,
      "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": 14550 },
      { "label": "Total", "amount": 239550 }
    ],
    "is_free": false,
    "is_test_mode": false,
    "fee_rate": { "flat_fee": 1500, "percent_fee": 5.8, "currency": "UGX", "payment_method": "card" }
  }
}
```

```json POST /v1/orders/Wn2dG6jR/pay answers 200: redirect the buyer theme={null}
{
  "code": 200,
  "message": "Continue on the hosted payment page",
  "data": {
    "order_id": "Wn2dG6jR",
    "order_code": "LC-5B9K3T",
    "status": "cart",
    "total": 239550,
    "currency": "UGX",
    "next_action": { "kind": "redirect", "redirect_url": "https://laces.run/pay?order=Wn2dG6jR" },
    "skipped_provider": false,
    "prompt_expires_at": null
  }
}
```

New: after the Laces card page, the buyer comes back to your `on_success_url`
or `on_failure_url` with `laces_order_id` and `laces_status` added. That is
**not** proof of payment.

## Step 6: Handle every outcome

```json Webhook: order.paid (fulfil once) 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"
    }
  }
}
```

```json Webhook: order.failed (once per order; the buyer may retry, release nothing yet) theme={null}
{
  "id": "LCSWHD-E5C70A29D4B8461F93A2C7D0B18F6E54",
  "type": "order.failed",
  "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": "failed",
      "currency": "UGX",
      "subtotal": 225000,
      "discount_total": 0,
      "donation_total": 0,
      "laces_fee": 9500,
      "total": 234500,
      "failure_kind": "declined",
      "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"
    }
  }
}
```

```json Webhook: order.refunded (the price only) theme={null}
{
  "id": "LCSWHD-60F9A3D7C1E84B25B7D3F0A9C5E21846",
  "type": "order.refunded",
  "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": "refunded",
      "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"
    },
    "refund": { "id": "rf_5pN3", "amount": 225000, "status": "completed" }
  }
}
```

```json GET /v1/orders/Zs5kF8nA: paid theme={null}
{
  "code": 200,
  "message": "Order retrieved successfully",
  "data": {
    "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",
    "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": null,
    "prompt_expires_at": null,
    "created_at": "2026-11-25T08:14:03.000Z"
  }
}
```

```json GET /v1/orders/Zs5kF8nA: failed theme={null}
{
  "code": 200,
  "message": "Order retrieved successfully",
  "data": {
    "id": "Zs5kF8nA",
    "order_code": "LC-4T7X2M",
    "order_type": "partner_payment",
    "status": "failed",
    "currency": "UGX",
    "subtotal": 225000,
    "discount_total": 0,
    "donation_total": 0,
    "laces_fee": 9500,
    "total": 234500,
    "failure_kind": "declined",
    "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": null,
    "prompt_expires_at": null,
    "created_at": "2026-11-25T08:14:03.000Z"
  }
}
```

```json GET /v1/orders/Zs5kF8nA: expired (no webhook if the buyer walked away) theme={null}
{
  "code": 200,
  "message": "Order retrieved successfully",
  "data": {
    "id": "Zs5kF8nA",
    "order_code": "LC-4T7X2M",
    "order_type": "partner_payment",
    "status": "expired",
    "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": null,
    "prompt_expires_at": null,
    "created_at": "2026-11-25T08:14:03.000Z"
  }
}
```

```json Create or quote before Laces turns payments on: 403 theme={null}
{
  "code": 403,
  "message": "shop_payments_not_enabled",
  "error": "Payments are not enabled for this organization",
  "error_code": "shop_payments_not_enabled"
}
```

```json Pay: too many prompts to one number: 429 theme={null}
{
  "code": 429,
  "message": "payer_prompt_limit",
  "error": "Too many payment requests have been sent to this number. Please wait before trying again, or use a different number.",
  "details": { "retry_after_seconds": 1800 },
  "error_code": "payer_prompt_limit"
}
```

Every code: [Errors](https://docs.laces.run/payments/errors.md). Signature check and a full handler:
[Webhooks](https://docs.laces.run/payments/webhooks.md).

## Step 7: Close sales on the Laces event

When new payments arrive, **close** the event in the Laces app so nobody can
still buy there. **Do not delete it**: its orders, refunds and history hang off
it. Closing stops new orders; an order created before it can still be paid, so
keep handling both kinds. Checkout sessions already open can't start new orders
on a closed event.

**Selling on both at once?** Don't: Laces counts only its own places. If you
must, split the places between the two.

## Rolling back

Point your server at `POST /orders` again and reopen the event. Payments
already created can still be paid, and stay as payments: before you create a
ticket order, read the registration's payments, as `look` does, and go on only if
none is paid or could be. Keep the handler for both kinds.

## Checklist

* [ ] Laces has turned payments on for the organization
* [ ] `payments:write`, `orders:write` and `orders:read` are on the key, and the token is new
* [ ] The site is in **Return URL domains**
* [ ] In this order, before payments are turned on: deadline job paused, backfill, webhook handler deployed, backfill again, deadline job restarted
* [ ] Every registration whose places were already given back has `released` set before the job restarts
* [ ] A ticket order of another API key is matched by order id only, never by reference
* [ ] The webhook handler works without `event_id` and `registrations`, accepts both kinds of order, and both fulfil and undo through the shared code
* [ ] A ticket order that can't be matched, or has another total, goes to review
* [ ] A registration's ticket orders are read before a payment is created **and** before pay, and two paid orders for one registration are flagged
* [ ] Prices come from the quote; `amount` has no fee in it
* [ ] One payment per registration, `amount` is the sum, `product` never changes for this event
* [ ] `partner_reference` is always sent; `metadata` holds an id, no attendee or child data
* [ ] The consent, attendee list, tickets and check-in are on your side
* [ ] Places are reserved before the payment and released by you
* [ ] Fulfilment only when a server read says `paid` now, once
* [ ] `requested_amount` and `requested_currency` are compared with your price (payments only)
* [ ] No fixed fee or rate is left in your code
* [ ] The old event is closed, not deleted
* [ ] One small real payment was made by a person, and refunded if wanted

## A prompt for your LLM

Copy this. It contains no secrets: keep it that way.

```text theme={null}
You are changing an existing server from Laces event orders to Laces payments only.

Read these pages first (each is plain Markdown):
https://docs.laces.run/payments/move-from-event-orders.md
https://docs.laces.run/guides/collect-payments.md
https://docs.laces.run/payments/mobile-money.md
https://docs.laces.run/payments/card.md
https://docs.laces.run/payments/countries-and-currencies.md
https://docs.laces.run/payments/webhooks.md
https://docs.laces.run/payments/errors.md
https://docs.laces.run/payments/going-live.md
The index of every page is https://docs.laces.run/llms.txt

Rules:
1. Never ask for, print or store a client secret, webhook secret or access
   token. Read them from environment variables on the server only. Never send
   them to a browser.
2. Never call POST /orders/{orderId}/pay on the live API. It moves real money.
   There is no sandbox. Test against a local fake that returns the example
   payloads from the pages above. A person makes the first real payment.
3. Do not invent fields, routes or error codes. If the pages don't say, stop
   and ask me.
4. Never calculate the Laces fee. Show what POST /payments/quote returns.
   `amount` is the item price before the fee, an integer in minor units.

Change:
- POST /orders becomes POST /payments. Send no event_id and no organization id.
- GET /events/{eventId} for prices becomes POST /payments/quote.
- Keep POST /orders/{orderId}/pay, GET /orders/{orderId}, the token code and the
  webhook signature check.
- The webhook handler must work without event_id, ticket_count and
  registrations. Match on data.order.id, then partner_reference. Accept both
  order types: data.order.order_type is "partner_payment" for a payment and
  absent for a ticket order.
- Webhooks cover every order of the organization. Ignore (answer 200) a PAYMENT
  whose attribution.api_client_id is not ours. Do not apply that check to ticket
  orders: theirs can be another id or null. Send a payment we can't match to
  review; never crash on it.
- Fulfil a payment only after a server-side read says its status is "paid" now
  (the webhook tells you when to read), and requested_amount and
  requested_currency match my price. Ticket orders don't have those two fields:
  keep our existing check for them. Fulfil once, even if events repeat or arrive
  out of order, and never an order that was refunded.
- Flag two paid orders for the same registration, ticket order or payment.
- Ticket orders and payments share fulfilled/undone/released per registration,
  and fulfil and undo through the same code. Match a ticket order by id, then
  attribution.partner_reference ONLY if attribution.api_client_id is ours. Ours
  but unmatched, another key's with our reference, or another total: review,
  attached to nothing.
- Cut over in this order: pause the deadline job, add the columns and backfill
  them (fulfilled from confirmed ticket orders, then released where the old code
  gave the places back), deploy the handler, backfill again, restart
  the job, then payments. A refunded order that we had not cancelled: review.
- The deadline job reads ticket orders too, under the same lock as pay, waits 3
  minutes after an unanswered pay, and never releases a fulfilled registration.
  Create and pay stop once it is fulfilled, undone or released. Paid after its
  places were given back: review, never fulfil.
- On order.refunded, undo a registration only if that order id is the one that
  fulfilled it, and only ONCE. Add up refund.amount per order id and compare with
  the price, subtotal - discount_total + donation_total (the same on ticket
  orders and payments), never with total: a refund returns the price, not the
  fee. Less than the price: review. A refund event after the undo (the fee can
  come back later): record it, do nothing else. Fulfil and undo under one lock
  per registration.
- Never release places on order.failed. At our own deadline read the order.
- The return URL is never proof of payment.
- Save one record per attempt with its own create key and pay key. Reuse the
  create key on timeouts and 5xx. Never retry pay automatically: after a timeout
  or 5xx read the order, and pay again only when the buyer asks and the order is
  not payment_initiated or prompt_sent. Use new keys when the body, number or
  method changes, or when the buyer retries.
- For hold_expired, rate_lock_expired and reprice_required, or an order older
  than 15 minutes: read the old order, then create a new payment with new keys
  and keep the old id. Before any create or pay, read EVERY order of the purchase:
  go on only if all are cart, failed, expired or cancelled; otherwise stop.
  Lock per purchase. After a pay call with no answer, wait 3 minutes before
  believing cart, or an earlier failed or expired. There is no reprice or cancel route.
- Show the total from the create answer before calling pay.
- Send msisdn with its country code for any number outside Uganda.
- Put no attendee or child data in metadata, only an id from our system.
- Page GET /orders until next_cursor is null; a page may be short or empty.

Show me the plan and the files you will change before you edit anything. When
done, list each item of the checklist on the move page and how you checked it.
```


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