Examples
Sandbox Examples
Every sandbox request runs against a mock payment network — no real money moves, no real SMS is sent, and nothing settles. Build and test your entire integration before switching to a live key.
Getting a sandbox key
Generate one from the dashboard's API Keys page (choose the Sandbox tab), or via POST /v1/merchants/{id}/api-keys with "environment": "sandbox" — see API Key Authentication.
How sandbox collections behave
A sandbox key routes POST /v1/collections/{wallet-push,selcom-pesa,qr} to a fully simulated flow — Selcom is never called, and nothing ever touches a real wallet balance. The collection resolves to successful immediately by default. Pass simulate_status to test a different outcome:
| simulate_status | Result |
|---|---|
| successful (default) | Collection resolves as paid |
| failed | Collection resolves as failed |
| pending_clearance | Held for manual clearance, same as a real self-payment/risk hold |
| reversed | Resolves as a settled-then-reversed payment |
curl -X POST https://api.infinityafrica.net/v1/collections/wallet-push \
-H "Authorization: Bearer $INFINITY_SANDBOX_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"merchant_id":"...","amount":1000,"phone":"255700000000","simulate_status":"failed"}'simulate_status is sandbox-only
live key is rejected outright (422) — it never silently does nothing.One boundary worth knowing: this simulation only covers the three direct push/QR endpoints above — the "Infinity Payment Page" flow (POST /v1/collections, the customer-facing checkout page) is not sandbox-aware yet and always runs the real flow regardless of which key created it.
A full sandbox test flow
- Generate a sandbox key and set it as your X-API-Key.
- Create a payment link (
POST /v1/payment-links) and openpublic_urlin a browser. - Complete checkout — the mock provider resolves it within the same request, roughly 90% of the time successfully.
- Check
GET /v1/merchants/{id}/transactionsand confirm a ledger entry appeared. - Request a small disbursement and watch it resolve to SUCCESS or FAILED.
- Point your webhook_url at a local tunnel (e.g. ngrok) and confirm delivery of the resulting events.