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

# Checkout API flow

> Create a frozen invoice, let the customer authorize payment, and reconcile verified evidence.

This reference follows the current mainnet availability: checkout and fees are live, while a complete CCTP bridge has not been verified. Hosted and embedded checkout render the frozen invoice recipient, and creating an invoice does not submit a payment. Read [mainnet availability](https://docs.flarehq.xyz/payments/availability.md).

**The customer pays directly to the merchant wallet; FlareHQ never holds checkout funds.**

## 1. Create an invoice

Use [POST /api/payments/initialize](https://docs.flarehq.xyz/api-reference/payments/initialize.md) with a verified active merchant's server-side API key. The server resolves the merchant identity and payout wallet. The resolver also has distinct consumer-session and internal-service-key paths; it does not accept a bare merchant session here.

The validated amount is a positive decimal with up to 6 places. Mainnet merchant invoice settlement is USDC-only. Creation returns `reference`, `checkoutUrl`, `data.status: 'ready'` and canonical token identity. The stored invoice is `PENDING`, with a 120-minute expiry. No payment has been made.

Each successful initialize POST creates a new reference. Persist it against your order; there is no client order-idempotency key. [Merchant payment links](https://docs.flarehq.xyz/api-reference/payments/payment-links.md) are a separate merchant-key/session path with a 24-hour expiry.

## 2. Open hosted or embedded checkout

Use the returned `/checkout/{reference}` or `/checkout/embed/{reference}` URL. A bare `/checkout` or `/pay` URL is not a valid invoice. The embed reuses the hosted payment widget.

The widget signs through the connected browser wallet. The logged-in Circle consumer and WalletConnect EOA can be different accounts; consumer login or existing EOA payment history does not authorize assistant spending from that EOA.

The embed sends messages with `source: 'flarehq-checkout'`:

| Type | Fields beyond `source` and `type` |
| - | - |
| `ready` | `reference` |
| `status` | `reference`, `status` |
| `payment_success` | `reference`, `status`, `txHash` |
| `payment_error` | `reference`, `message` |
| `resize` | `height` |

Messages use wildcard target origin. In the parent, check the expected FlareHQ `event.origin`, the specific iframe's `contentWindow` against `event.source`, the message shape and saved reference. Treat messages as UI hints, not fulfillment proof. The reviewed framing configuration allows embedding on this route; no per-merchant registered origin allowlist is implemented.

## 3. Authorize and verify the transaction

The customer's wallet authorizes payment. The public, payments-rate-limited proof endpoint is:

```text theme={null}
POST /api/payments/verify-onchain
Content-Type: application/json
{ "reference": "<saved-reference>", "txHash": "<actual-mined-hash>" }
```

This request is illustrative. Do not submit it for a payment or fee that is already settled; inspect paid invoices with GET/read-only evidence.

For direct payment, the server reads the configured chain receipt and matches the canonical token's `Transfer` into the frozen merchant wallet with amount at least the invoice amount. It also checks the execution block does not predate the invoice. One `(chainId, txHash, logIndex)` proof cannot settle two invoices; proof consumption and success persistence are transaction-bound.

An invoice carrying a conversion instead requires evidence for its saved quote/venue. A random token transfer cannot replace that execution. Do not manufacture quote, router, recipient or amount fields; use the existing checkout flow. End-to-end mainnet swaps remain unverified.

Fresh verification returns `success: true` with `payment`; a previously successful reference returns `success: true, alreadySettled: true`. The latter short-circuits payment verification and can retry a pending or failed platform fee; it does **not** validate a newly supplied hash. Platform fees are separate, best-effort and cannot roll back a successful customer payment. Inspect paid invoices with GET/read-only evidence unless fee recovery is separately authorized.

Never reuse a transaction proof for a different invoice. Bind each saved order to its own invoice reference and verified payment.

`POST /api/checkout/pay` does **not** exist. There is no public shared-wallet settlement trigger or automatic bridge path at that URL.

## 4. Reconcile before fulfillment or retry

[GET /api/payments/verify/{reference}](https://docs.flarehq.xyz/api-reference/payments/verify.md) reads cached database state. Top-level `status: true` is query success; require `data.status === 'SUCCESS'` for payment state. `paid_at` is a legacy creation timestamp, not mined settlement evidence.

Compare the saved order, canonical token/amount, frozen recipient, receipt, recipient credit and payment row. Derive expiration from `expiresAt` when a cached row remains `PENDING`. Do not issue a second transfer merely because a request timed out.

Outbound [webhooks](https://docs.flarehq.xyz/developers/webhooks.md) are unsigned and best-effort. Use your own durable order mapping and fulfill once transactionally. Merchant history exists at [GET /api/payments/all](https://docs.flarehq.xyz/api-reference/payments/history.md); no `/api/payments/history` route exists.


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