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_statusResult
successful (default)Collection resolves as paid
failedCollection resolves as failed
pending_clearanceHeld for manual clearance, same as a real self-payment/risk hold
reversedResolves as a settled-then-reversed payment
bash
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"}'
info

simulate_status is sandbox-only

Sending it with a 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

  1. Generate a sandbox key and set it as your X-API-Key.
  2. Create a payment link (POST /v1/payment-links) and open public_url in a browser.
  3. Complete checkout — the mock provider resolves it within the same request, roughly 90% of the time successfully.
  4. Check GET /v1/merchants/{id}/transactions and confirm a ledger entry appeared.
  5. Request a small disbursement and watch it resolve to SUCCESS or FAILED.
  6. Point your webhook_url at a local tunnel (e.g. ngrok) and confirm delivery of the resulting events.