ChapaChapa Docs

Testing Cards

Use test cards to safely validate card payment flows in Test Mode without moving real money.

Testing Cards allow you to safely test card payment flows in Test Mode without moving real money.

They help you validate:

  • Payment initialization
  • Successful and failed transactions
  • Webhook delivery
  • Verification and reconciliation logic

Test cards only work in Test Mode. They will always fail in Live Mode.

When to Use Test Cards

Use test cards when you want to:

  • Integrate card payments during development
  • Simulate different transaction outcomes
  • Verify webhook handling and payment verification
  • Test edge cases like failures or insufficient funds

Test Mode Requirement

Before using test cards:

  • Use a test secret key (CHAPA_TEST_...)
  • Ensure your environment is set to test
  • Use test checkout URLs or test direct charge flows

Using test cards with live keys will fail.

Supported Test Card Details

Success Card

FieldValue
Card Number4242 4242 4242 4242
Expiry DateAny future date
CVVAny 3 digits
Cardholder NameAny name

Expected Result: Payment succeeds


Insufficient Funds (Failure)

FieldValue
Card Number4000 0000 0000 9995
Expiry DateAny future date
CVVAny 3 digits
Cardholder NameAny name

Expected Result: Payment fails with INSUFFICIENT_FUNDS


Generic Decline

FieldValue
Card Number4000 0000 0000 0002
Expiry DateAny future date
CVVAny 3 digits
Cardholder NameAny name

Expected Result: Payment fails with generic decline

Example Test Flow

  1. Initialize payment (Hosted or Direct Charge)
  2. Use a test card on checkout
  3. Observe response: success or failed
  4. Receive webhook event: payment.success or payment.failed
  5. Verify payment using:
GET /v2/payments/{reference}/verify

Webhook Events in Test Mode

Webhook payloads in test mode include:

{
  "mode": "test"
}

This allows you to:

  • Separate test vs live processing
  • Prevent test data from affecting production logic

Common Test Scenarios

ScenarioWhat to Test
Successful paymentEnd-to-end flow
Failed paymentError handling
Webhook deliverySignature & retries
VerificationStatus consistency
TimeoutsIncomplete payments

Best Practices

  • Never use real card data in test mode
  • Clearly label test transactions in your database
  • Ignore test webhooks in production systems
  • Test all status transitions before going live

Common Errors

ErrorCause
Card declinedUsing test card in live mode
Invalid card numberIncorrect test card format
Authentication failedUsing live key with test card

Next Steps

On this page