PayGate

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:

EnvironmentAPI Key PrefixBase URLDescription
Testsk_test_api.sandbox.paygate.com.ghFor development and testing
Livesk_live_api.paygate.com.ghFor 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 NumberProviderBehavior
0241234567MTNSucceeds immediately
0201234567TelecelSucceeds immediately
0271234567AirtelTigoSucceeds immediately

Pending then Successful

Phone NumberProviderBehavior
0241234568MTNStays pending for 30s, then succeeds
0201234568TelecelStays pending for 30s, then succeeds
0271234568AirtelTigoStays pending for 30s, then succeeds

Failed Payments

Phone NumberBehaviorError Code
0241234560Insufficient fundsinsufficient_funds
0241234561Transaction declinedtransaction_declined
0241234562Phone unreachablephone_unreachable
0241234563Timeout (no response)timeout
0241234564Invalid PINinvalid_pin
0241234565Daily limit exceededlimit_exceeded

Test Amounts

You can use any amount in test mode, but certain amounts trigger specific behaviors:

Amount (pesewas)Behavior
Any amountNormal processing
99999999Fails with amount_too_large
100Minimum amount (GHS 1.00)

Testing Webhooks

Using the Dashboard

  1. Go to Settings > Webhooks in your Dashboard
  2. Add your local webhook URL (use a tool like ngrok for local development)
  3. 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:

  1. No real mobile money prompts - Customers won't receive actual payment prompts
  2. Simulated responses - All responses are simulated based on test phone numbers
  3. No real money movement - No actual funds are transferred
  4. Faster timeouts - Pending payments resolve faster than in production
  5. Rate limits are relaxed - Higher rate limits for easier testing

Going Live

When you're ready to accept real payments:

  1. Complete the Go Live Checklist
  2. Switch to your live API keys (sk_live_...)
  3. Update your base URL to production
  4. Test with a small real transaction

See our Go Live Guide for a complete checklist before going to production.