Sandbox Testing
Test your integration safely before going live
The sandbox environment lets you test your integration without making real purchases or affecting production data.
Sandbox vs Production
| Aspect | Sandbox | Production |
|---|---|---|
| Base URL | /api/partners/sandbox/v1 | /api/partners/v1 |
| API Key Prefix | sk_test_ | sk_live_ |
| Real Transactions | No | Yes |
| Real Charges | No | Yes |
| Webhooks | Test payloads | Real events |
| Rate Limits | 60/min (all tiers) | Tier-based |
| Max Webhooks | 1 | 3 |
Getting Sandbox Credentials
- Go to Settings > API Keys
- Click Create New Key
- Select Sandbox environment
- Copy your
sk_test_key
Making Sandbox Requests
Use the sandbox base URL with your test key:
curl -X GET \
-H "Authorization: Bearer sk_test_your_test_key" \
https://my.rizpay.app/api/partners/sandbox/v1/account/balance
Sandbox Behavior
Account Balance
Returns a mock balance for testing:
{
"status": { "code": 200, "message": "Success" },
"data": {
"balance": "100000.00",
"currency": "NGN",
"updated_at": "2024-01-15T10:30:00Z"
}
}
Products
Returns real product data. Use these products in your test purchases.
Purchases
Creates mock transactions whose outcome is selected by the configured test recipient. A purchase can be immediately successful, pending, failed or reversed. Unrecognized test recipients fail with PURCHASE_FAILED; a valid phone or meter format alone does not select a successful scenario.
No real airtime or data is delivered. No balance is deducted.
# Replace prd_42 with an MTN product ID from your own catalogue response.
# Generate and persist a new external_reference for this test order.
curl -X POST \
-H "Authorization: Bearer sk_test_your_test_key" \
-H "Content-Type: application/json" \
-d '{
"product_id": "prd_42",
"network": "MTN",
"phone_number": "08022222222",
"amount": "100.00",
"external_reference": "1736234400T3S4T5"
}' \
https://my.rizpay.app/api/partners/sandbox/v1/purchases
Transaction Status
For the pending-success scenario above, query the returned transaction ID to simulate completion:
# Replace the transaction ID with data.id from your purchase response.
curl -X POST \
-H "Authorization: Bearer sk_test_your_test_key" \
https://my.rizpay.app/api/partners/sandbox/v1/purchases/txn_abc123/query
This scenario becomes successful. The query endpoint completes any pending sandbox transaction as successful, whichever scenario created it, so leave a pending-failure scenario to its scheduled transition instead of querying it. Query only pending transactions; a completed transaction returns INVALID_STATUS. Read any existing transaction with GET /purchases/:id and inspect data.attributes.status.
Webhooks
Sandbox webhooks fire with test payloads. Use them to:
- Test your webhook endpoint
- Verify signature validation
- Debug payload handling
Test Phone Numbers
For airtime and data, use these simulator inputs:
| Phone number | Scenario |
|---|---|
08011111111 | Immediately successful |
08022222222 | Pending, then successful |
08033333333 | Pending, then failed |
08044444444 | Failed with INSUFFICIENT_BALANCE |
08066666666 | Reversed |
Airtime also supports 08055555555 for VALIDATION_ERROR. Any unrecognized number fails with PURCHASE_FAILED. Pending scenarios transition on their own after about 30 seconds. Wait for that transition when you are testing a pending-then-failed scenario; querying the transaction completes it as successful instead.
Test Meter/Decoder Numbers
Choose the fixture for the scenario you need:
| Product | Test identifier | Scenario |
|---|---|---|
| Electricity | 11111111111 | Successful prepaid purchase with a simulated token |
| Electricity | 22222222222 | Successful postpaid payment |
| Electricity | 33333333333 | Pending, then successful |
| Electricity | 44444444444 | Failed with VALIDATION_ERROR |
| Electricity | 55555555555 | Failed with SERVICE_UNAVAILABLE |
| Electricity | 66666666666 | Reversed |
| Cable TV | 1212121212 | Immediately successful |
| Cable TV | 2020202020 | Pending, then successful |
| Cable TV | 3030303030 | Failed with VALIDATION_ERROR |
| Cable TV | 4040404040 | Reversed |
Keep these identifiers as strings and submit the product-specific fields from the electricity or cable TV reference. Verify the meter or decoder before purchasing. These values select simulated outcomes only; do not use them as recipients for production purchases.
Environment Isolation
Sandbox and production are completely isolated:
| Aspect | Behavior |
|---|---|
| API Keys | Sandbox keys only work on sandbox endpoints |
| Transactions | Sandbox transactions don't appear in production |
| Webhooks | Configured separately for each environment |
| Data | No data sharing between environments |
Attempting to use a sandbox key on production (or vice versa) returns:
{
"status": {
"code": 403,
"message": "Forbidden"
},
"error": {
"code": "ENVIRONMENT_MISMATCH",
"message": "Sandbox API keys can only access sandbox endpoints"
}
}
Testing Checklist
Before going live, verify:
- Authentication - API key works correctly
- Products - Can list and filter products
- Purchases - Can create purchases
- Status Checks - Can query transaction status
- Verification - Meter/decoder verification works (electricity/cable)
- Error Handling - Handles all error codes gracefully
- Webhooks - Receives and verifies webhook payloads
- Rate Limits - Handles 429 responses correctly
- Duplicate Prevention - External reference prevents duplicates
Going Live
When you're ready for production:
- Create a production API key (
sk_live_) - Update your base URL to
/api/partners/v1 - Configure production webhooks
- Test with small amounts first
- Monitor your first few transactions
Next Steps
- Quick Start - Make your first API call
- Webhooks - Set up webhook testing