One payment, end to end
From a signed price to a release on QIE, with the real timings of a test-build order and every place it can turn into a refund.


Price
POST /api/quotes checks the bill and the limits, converts naira to QUSDC at the reference rate less 1%, asks QIEDEX for an exact-out quote when paying in QIE, stores the order as quoted with a random 32-byte order id, and signs Quote(payer, orderIds, amounts, expiry) with EIP-712. The price expires in 60 seconds, which is also the swap's deadline.
Pay
The wallet simulates, then sends payWithQIE(quote, sig) with the "at most" QIE as value (gas limit = estimate × 1.2), or approves and sends payWithQUSDC. The app posts the transaction hash to POST /api/orders/{id}/tx at once and polls the order every 2 seconds.
Held
The escrow emits OrderPaid(orderId, payer, amount, asset). The indexer (every 4 seconds) or the fast path reads it, checks the payer and amount match the stored order, and moves it to held. That queues a delivery.vend job.
Buy
The worker writes a request id (Lagos YYYYMMDDHHmm + 12 random characters) and a dispatch stamp before calling VTpass, then calls pay once. It never retries a purchase blindly: an unclear answer becomes a requery.
Settle
Delivered → release(orderId); failed → refund(orderId, reason). Both go through the operator's signing lane, which first reads the order on chain to confirm it is still Held, stores the signed transaction, then broadcasts. OrderReleased or OrderRefunded moves the order to released or refunded.
After
Released orders pay cashback and invite rewards; Telegram sends the notice. If nothing settles, the payer can reclaim after the delay.
Where it can turn
| Moment | What happens |
|---|---|
| Price expires before payment | Order expired. A late OrderPaid before the on-chain expiry still counts |
| Provider closed, paused or out of float | Fails before buying, refunded |
| Provider says failed or reversed | Refunded, reason code on chain |
| Provider unsure | Asked again after 15 s, then 1 min later, 5 min later, then every 15 min; after 24 h, needs_review for an operator |
| Delivered after a refund | delivered_after_refund: the payer keeps the bill and the money; Todoku logs the loss |
| Nobody settles | The payer reclaims after RECLAIM_DELAY |