1. Create an invoice
Use POST /api/payments/initialize 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 returnsreference, 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 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':
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: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/ reads cached database state. Top-levelstatus: 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 are unsigned and best-effort. Use your own durable order mapping and fulfill once transactionally. Merchant history exists at GET /api/payments/all; no /api/payments/history route exists.
