PAID once the SettlementRecorded event is observed. Every USDC settlement you see as CONFIRMED maps to a verifiable onchain transaction.
What happens when you settle
When youPOST a new settlement, Retempo executes the following steps automatically:
Create the settlement record
Retempo creates a settlement record with status
PENDING, linking it to the invoice, payer, and merchant you specified.Submit to Arc
The backend calls
RetempoSettlement.recordSettlement() on the Arc smart contract, submitting the settlement onchain.Wait for the transaction receipt
Retempo waits for the Arc transaction to be mined and retrieves the onchain receipt. If the transaction reverts or times out, the settlement moves to
FAILED.Observe the SettlementRecorded event
Once the receipt confirms success, Retempo checks that the
SettlementRecorded event was emitted by the Arc contract. If the event is observed, the settlement moves to CONFIRMED.Creating a settlement
To create a settlement, send aPOST request to /api/v1/settlements. You must supply an invoiceId and a referenceHash. The referenceHash must be a 32-byte hex value — the 0x prefix followed by exactly 64 hexadecimal characters.
You also need to supply payerAddress (the subscriber’s wallet) and merchantAddress (the service owner’s wallet). Retempo validates that the payerId matches the invoice’s userId and that the merchantId matches the service’s ownerId before submitting to Arc.
chain object that contains the raw Arc transaction details:
Settlement statuses
A settlement transitions through the following statuses as it moves from creation to finality:| Status | Meaning |
|---|---|
PENDING | The settlement record has been created. The transaction has not yet been submitted to Arc. |
SUBMITTED | The transaction has been sent to Arc and Retempo is waiting for a receipt. |
CONFIRMED | Arc returned a successful receipt and the SettlementRecorded event was observed. The linked invoice has been marked PAID. |
FAILED | The transaction failed onchain, timed out, or the SettlementRecorded event was not observed. The invoice remains unpaid. You may create a new settlement to retry. |
Fetching a settlement
To retrieve the current state of a settlement along with its linked invoice, service, payer, and merchant, send aGET request with the settlement ID:
If you fetch a settlement with status
SUBMITTED, Retempo automatically re-checks Arc for the latest receipt before returning the response. The status you receive reflects the most up-to-date onchain state — no need to poll separately.Idempotency
If you submit aPOST /api/v1/settlements request with an invoiceId and referenceHash that already correspond to a CONFIRMED settlement, Retempo returns 200 with the existing settlement record instead of creating a duplicate. You do not need to track whether a settlement has already been confirmed — Retempo handles this for you.
This means it is safe to retry a settlement request if you experience a network timeout or are unsure whether your first request landed. If the settlement is already confirmed, you’ll get the existing record back at no cost.