Test Mode
Learn how to use test mode to develop and test your PayGate integration.
Test Mode
Test mode allows you to develop and test your PayGate integration without processing real payments or moving real money.
Test vs Live Mode
PayGate provides two environments:
| Environment | API Key Prefix | Base URL | Description |
|---|---|---|---|
| Test | sk_test_ | api.sandbox.paygate.com.gh | For development and testing |
| Live | sk_live_ | api.paygate.com.gh | For production transactions |
All test mode transactions are simulated. No real money is moved and no real mobile money prompts are sent.
Test API Keys
Get your test API keys from the Dashboard. Test keys always start with sk_test_ or pk_test_.
import PayGate from '@paygate/node'
// Test mode - use your test secret key
const paygate = new PayGate('sk_test_...')
// Live mode - use your live secret key
const paygateLive = new PayGate('sk_live_...')Test Phone Numbers
Use these phone numbers to simulate different payment scenarios:
Successful Payments
| Phone Number | Provider | Behavior |
|---|---|---|
0241234567 | MTN | Succeeds immediately |
0201234567 | Telecel | Succeeds immediately |
0271234567 | AirtelTigo | Succeeds immediately |
Pending then Successful
| Phone Number | Provider | Behavior |
|---|---|---|
0241234568 | MTN | Stays pending for 30s, then succeeds |
0201234568 | Telecel | Stays pending for 30s, then succeeds |
0271234568 | AirtelTigo | Stays pending for 30s, then succeeds |
Failed Payments
| Phone Number | Behavior | Error Code |
|---|---|---|
0241234560 | Insufficient funds | insufficient_funds |
0241234561 | Transaction declined | transaction_declined |
0241234562 | Phone unreachable | phone_unreachable |
0241234563 | Timeout (no response) | timeout |
0241234564 | Invalid PIN | invalid_pin |
0241234565 | Daily limit exceeded | limit_exceeded |
Test Amounts
You can use any amount in test mode, but certain amounts trigger specific behaviors:
| Amount (pesewas) | Behavior |
|---|---|
| Any amount | Normal processing |
99999999 | Fails with amount_too_large |
100 | Minimum amount (GHS 1.00) |
Testing Webhooks
Using the Dashboard
- Go to Settings > Webhooks in your Dashboard
- Add your local webhook URL (use a tool like ngrok for local development)
- Click Send test webhook to trigger test events
Using the CLI
# Trigger a test webhook event
curl -X POST https://api.sandbox.paygate.com.gh/v1/webhooks/test \
-H "Authorization: Bearer sk_test_..." \
-H "Content-Type: application/json" \
-d '{
"event_type": "payment.succeeded",
"webhook_id": "wh_abc123"
}'Simulating Different Scenarios
Successful Payment Flow
// Create a payment that will succeed
const payment = await paygate.payments.create({
amount: 5000,
currency: 'GHS',
payment_method: 'mobile_money',
provider: 'mtn',
phone: '0241234567', // Always succeeds
description: 'Test payment'
})
// Payment succeeds immediately in test mode
console.log(payment.status) // 'succeeded'Failed Payment Flow
// Create a payment that will fail
const payment = await paygate.payments.create({
amount: 5000,
currency: 'GHS',
payment_method: 'mobile_money',
provider: 'mtn',
phone: '0241234560', // Insufficient funds
description: 'Test failed payment'
})
console.log(payment.status) // 'failed'
console.log(payment.failure_code) // 'insufficient_funds'Async Payment Flow
// Create a payment that stays pending then succeeds
const payment = await paygate.payments.create({
amount: 5000,
currency: 'GHS',
payment_method: 'mobile_money',
provider: 'mtn',
phone: '0241234568', // Pending then succeeds
description: 'Test async payment'
})
console.log(payment.status) // 'pending'
// Wait for webhook or poll after 30 seconds
// The payment will transition to 'succeeded'Test Mode Limitations
Test mode has some limitations compared to live mode:
- No real mobile money prompts - Customers won't receive actual payment prompts
- Simulated responses - All responses are simulated based on test phone numbers
- No real money movement - No actual funds are transferred
- Faster timeouts - Pending payments resolve faster than in production
- Rate limits are relaxed - Higher rate limits for easier testing
Going Live
When you're ready to accept real payments:
- Complete the Go Live Checklist
- Switch to your live API keys (
sk_live_...) - Update your base URL to production
- Test with a small real transaction
See our Go Live Guide for a complete checklist before going to production.