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 the mock provider behaves
A push or QR collection, and every disbursement, resolves with a configurable random failure rate — so your error-handling code gets exercised, not just the happy path. There's no need to configure anything; this is on by default in sandbox.
| Behavior | Default |
|---|---|
| Random failure rate | 10% |
| Simulated approval delay | ~0.3s |
Resolving a push/QR collection manually
Collections initiated via /v1/collections/{method} stay processing until a provider callback resolves them — in sandbox, that's simulated by posting to the same webhook endpoint a real Selcom callback would land on, signed with your merchant's webhook secret:
curl -X POST https://sandbox.infinityafrica.net/v1/webhooks/selcom \
-H "Content-Type: application/json" \
-H "X-Selcom-Signature: $(echo -n '{"event_id":"evt_1","event_type":"collection.success","provider_reference":"MOCK-SELCOM-9F3A1C2B"}' \
| openssl dgst -sha256 -hmac "$SELCOM_WEBHOOK_SECRET" | cut -d' ' -f2)" \
-d '{"event_id":"evt_1","event_type":"collection.success","provider_reference":"MOCK-SELCOM-9F3A1C2B"}'Use provider_reference from the collection or disbursement you want to resolve, and event_type of collection.success, collection.failed, disbursement.success, or disbursement.failed.
Public payment-link checkout resolves on its own
.../collect endpoint (what a customer hits on your checkout page) doesn't need this — it resolves synchronously in the same response, since the mock provider is called and checked immediately within that request.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.
