Skip to main content
Every call to POST /v1/payments can specify a scenario field that deterministically controls the simulation outcome: final status, latency, and error message. This is the primary lever for testing your failure paths.

Reference table

Latency is drawn randomly within the stated range on every call — reproducing the natural variance of a real operator.
Pass an explicit scenario to force a deterministic result (ideal for tests and CI). If you omit it, the outcome depends on your test client registry — see the section below.

Without a scenario: the SIM registry (test clients)

If you omit the scenario field, SandPay behaves like a real operator and uses your test clients (/clients in the dashboard) as a SIM registry:
Create at least one test client in /clients before sending a payment without a scenario, otherwise all numbers return UNKNOWN_MSISDN. For a deterministic result, pass an explicit scenario instead — it always takes precedence.
Configurable per environment: the unknownMsisdnPolicy is reject by default (unknown number → UNKNOWN_MSISDN). In passthrough mode, an unknown number is forwarded to the operator adapter (legacy behaviour). The blocked and insufficient-funds cases always remain final.

Example — triggering pin_invalid

Response:

Statuses and finality

The 11 canonical statuses are stable — your switch can enumerate them. PENDING is the only non-final status: it indicates a transaction is currently being processed (useful for async flows). All other statuses are final and trigger the payment.completed webhook.

Out-of-scenario: description

The description field (optional) is purely informational — it is stored on the transaction and returned in the webhook payload, but does not influence the outcome.

Raw operator response (raw)

Every payment resource (POST /v1/payments, GET /v1/payments/{id}, items in GET /v1/payments, and the payment.completed webhook) contains a raw field with the native operator shape corresponding to the scenario played. This shape is synthesised with _simulated: true at the top level — it faithfully reproduces the native structure returned by each operator. MTN example — scenario: "success":
Moov example — scenario: "low_balance":
Orange example — scenario: "success" (note: the SUCCESSFULL typo is faithfully reproduced from the real API):

See also