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
| Field | Value |
|---|---|
| Card Number | 4242 4242 4242 4242 |
| Expiry Date | Any future date |
| CVV | Any 3 digits |
| Cardholder Name | Any name |
Expected Result: Payment succeeds
Insufficient Funds (Failure)
| Field | Value |
|---|---|
| Card Number | 4000 0000 0000 9995 |
| Expiry Date | Any future date |
| CVV | Any 3 digits |
| Cardholder Name | Any name |
Expected Result: Payment fails with INSUFFICIENT_FUNDS
Generic Decline
| Field | Value |
|---|---|
| Card Number | 4000 0000 0000 0002 |
| Expiry Date | Any future date |
| CVV | Any 3 digits |
| Cardholder Name | Any name |
Expected Result: Payment fails with generic decline
Example Test Flow
- Initialize payment (Hosted or Direct Charge)
- Use a test card on checkout
- Observe response:
successorfailed - Receive webhook event:
payment.successorpayment.failed - Verify payment using:
GET /v2/payments/{reference}/verifyWebhook 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
| Scenario | What to Test |
|---|---|
| Successful payment | End-to-end flow |
| Failed payment | Error handling |
| Webhook delivery | Signature & retries |
| Verification | Status consistency |
| Timeouts | Incomplete 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
| Error | Cause |
|---|---|
| Card declined | Using test card in live mode |
| Invalid card number | Incorrect test card format |
| Authentication failed | Using live key with test card |
Next Steps
- Testing Mobile - Test mobile money payments
- Test vs Live Mode - Environment configuration
- Webhooks - Handle payment events