Testing
Test Scenarios
Comprehensive testing guide for Moneybag payment integration
Testing Scenarios
Complete guide for testing your Moneybag integration in sandbox environment before going live.
Sandbox Environment
Access Details
- API Endpoint:
https://sandbox.api.moneybag.com.bd/api/v2
- Dashboard: sandbox.moneybag.com.bd
- Test Credentials: Available in dashboard
Key Differences from Production
- No real money processed
- Simulated payment responses
- Data reset weekly
- Higher rate limits for testing
- Debug information in responses
Test Cards
Successful Payments
Card Number | Brand | Result | 3D Secure |
---|---|---|---|
4111 1111 1111 1111 | Visa | Success | No |
5555 5555 5555 4444 | Mastercard | Success | No |
3782 822463 10005 | Amex | Success | No |
4000 0000 0000 3220 | Visa | Success | Required |
Test Card Details:
- Expiry: Any future date (e.g., 12/25)
- CVV: Any 3 digits (4 for Amex)
- Name: Any name
- ZIP: Any valid postal code
Payment Failure Scenarios
Card Number | Error Code | Description |
---|---|---|
4000 0000 0000 0002 | CARD_DECLINED | Generic decline |
4000 0000 0000 9995 | INSUFFICIENT_FUNDS | Not enough balance |
4000 0000 0000 0069 | EXPIRED_CARD | Card expired |
4000 0000 0000 0127 | INVALID_CVV | Incorrect CVV |
4000 0000 0000 0119 | PROCESSING_ERROR | Bank error |
4000 0000 0000 3055 | FRAUD_SUSPECTED | Fraud detection triggered |
Mobile Banking Test Accounts
bKash Testing
Phone Number | PIN | OTP | Result |
---|---|---|---|
01700000001 | 12345 | 123456 | Success |
01700000002 | 12345 | 123456 | Insufficient funds |
01700000003 | 12345 | 123456 | Account blocked |
01700000004 | 12345 | 000000 | Invalid OTP |
Nagad Testing
Phone Number | PIN | OTP | Result |
---|---|---|---|
01800000001 | 12345 | 123456 | Success |
01800000002 | 12345 | 123456 | Daily limit exceeded |
01800000003 | 12345 | 123456 | Service unavailable |
Rocket Testing
Phone Number | PIN | OTP | Result |
---|---|---|---|
01900000001 | 12345 | 123456 | Success |
01900000002 | 12345 | 123456 | Transaction timeout |
01900000003 | 12345 | 123456 | Network error |
Amount-Based Test Triggers
Use specific amounts to trigger different scenarios:
Amount (BDT) | Scenario | Use Case |
---|---|---|
100.00 | Instant success | Happy path testing |
200.00 | Payment fails after 10 seconds | Timeout handling |
300.00 | Requires 3D Secure | Authentication flow |
400.00 | Random failure (50% chance) | Retry logic testing |
500.00 | Pending for 30 seconds | Status polling |
999.00 | Always fails | Error handling |
1234.56 | Partial refund scenario | Refund testing |
Test Scenarios by Feature
1. Basic Payment Flow
// Test Case 1: Successful Payment
describe('Successful Payment', () => {
it('should complete payment successfully', async () => {
const checkout = await createCheckout({
amount: 100.00,
card: '4111111111111111'
});
expect(checkout.status).toBe('SUCCESS');
expect(checkout.transaction_id).toBeDefined();
});
});
// Test Case 2: Failed Payment
describe('Failed Payment', () => {
it('should handle payment failure', async () => {
const checkout = await createCheckout({
amount: 999.00,
card: '4000000000000002'
});
expect(checkout.status).toBe('FAILED');
expect(checkout.error_code).toBe('CARD_DECLINED');
});
});
2. Webhook Testing
// Test webhook delivery
const testWebhook = {
event: 'payment.success',
data: {
transaction_id: 'TEST_TXN_001',
amount: 100.00,
status: 'SUCCESS'
}
};
// Trigger test webhook
curl -X POST https://sandbox.api.moneybag.com.bd/api/v2/webhooks/test \
-H "X-Merchant-API-Key: YOUR_KEY" \
-d '{
"url": "https://yoursite.com/webhook",
"event": "payment.success"
}'
3. Refund Testing
// Test full refund
async function testFullRefund() {
// Create payment
const payment = await createPayment(100.00);
// Process refund
const refund = await processRefund(payment.transaction_id);
expect(refund.status).toBe('COMPLETED');
expect(refund.amount).toBe(100.00);
}
// Test partial refund
async function testPartialRefund() {
const payment = await createPayment(1234.56);
const refund = await processRefund(payment.transaction_id, 500.00);
expect(refund.status).toBe('COMPLETED');
expect(refund.amount).toBe(500.00);
expect(refund.remaining_amount).toBe(734.56);
}
4. 3D Secure Testing
// Test 3D Secure flow
async function test3DSecure() {
const checkout = await createCheckout({
amount: 300.00,
card: '4000000000003220'
});
// Should redirect to 3D Secure
expect(checkout.requires_action).toBe(true);
expect(checkout.action_url).toContain('3dsecure');
// Simulate 3D Secure completion
const result = await complete3DSecure(checkout.action_url, '123456');
expect(result.status).toBe('SUCCESS');
}
5. Error Handling
// Test various error scenarios
const errorScenarios = [
{
name: 'Invalid API Key',
apiKey: 'invalid_key',
expectedError: 'INVALID_API_KEY'
},
{
name: 'Missing Required Field',
data: { amount: 100 }, // Missing customer
expectedError: 'VALIDATION_ERROR'
},
{
name: 'Invalid Amount',
data: { amount: -100 },
expectedError: 'INVALID_AMOUNT'
},
{
name: 'Duplicate Transaction',
orderId: 'DUPLICATE_001',
expectedError: 'DUPLICATE_TRANSACTION'
}
];
errorScenarios.forEach(scenario => {
test(scenario.name, async () => {
try {
await createCheckout(scenario);
fail('Should have thrown error');
} catch (error) {
expect(error.code).toBe(scenario.expectedError);
}
});
});
Integration Testing Checklist
Pre-Launch Testing
Payment Flow
- Successful payment completion
- Payment failure handling
- Payment cancellation flow
- Session timeout handling
- Browser back button behavior
Error Scenarios
- Network interruption
- Invalid card details
- Insufficient funds
- Expired session
- Rate limiting
Webhook Handling
- Webhook signature verification
- Duplicate webhook handling
- Webhook retry mechanism
- Missing webhook recovery
Refunds
- Full refund processing
- Partial refund handling
- Multiple partial refunds
- Refund failure scenarios
Security
- HTTPS enforcement
- API key security
- XSS prevention
- CSRF protection
- SQL injection prevention
User Experience
- Mobile responsiveness
- Loading states
- Error messages
- Success confirmations
- Email notifications
Load Testing
Performance Benchmarks
// Load test configuration
const loadTestConfig = {
concurrent_users: 100,
duration: '5m',
ramp_up: '30s',
scenarios: [
{
name: 'Checkout Creation',
weight: 70,
target_rps: 50
},
{
name: 'Payment Verification',
weight: 20,
target_rps: 100
},
{
name: 'Refund Processing',
weight: 10,
target_rps: 10
}
]
};
// Expected performance
const performanceTargets = {
checkout_creation: {
p95: 500, // 95th percentile < 500ms
p99: 1000, // 99th percentile < 1s
error_rate: 0.01 // < 1% errors
},
payment_verification: {
p95: 200,
p99: 500,
error_rate: 0.001
}
};
Stress Testing
# Using Apache Bench
ab -n 1000 -c 10 -H "X-Merchant-API-Key: YOUR_KEY" \
https://sandbox.api.moneybag.com.bd/api/v2/payments/checkout
# Using k6
k6 run --vus 100 --duration 5m load-test.js
Debugging Tools
Request Inspector
// Log all API requests for debugging
function debugRequest(config) {
console.log('=== API Request ===');
console.log('URL:', config.url);
console.log('Method:', config.method);
console.log('Headers:', config.headers);
console.log('Body:', JSON.stringify(config.data, null, 2));
console.log('==================');
return config;
}
// Log all responses
function debugResponse(response) {
console.log('=== API Response ===');
console.log('Status:', response.status);
console.log('Headers:', response.headers);
console.log('Body:', JSON.stringify(response.data, null, 2));
console.log('===================');
return response;
}
Test Data Generator
// Generate test data
function generateTestCustomer() {
return {
name: `Test User ${Date.now()}`,
email: `test${Date.now()}@example.com`,
phone: `+880170000${Math.floor(Math.random() * 9999)}`,
address: '123 Test Street',
city: 'Dhaka',
postcode: '1000'
};
}
function generateTestOrder(amount = 100) {
return {
order_id: `TEST_ORDER_${Date.now()}`,
amount: amount,
items: [
{
name: 'Test Product',
quantity: 1,
price: amount
}
]
};
}
Sandbox Limitations
What's Different in Sandbox
Feature | Sandbox | Production |
---|---|---|
Real payments | ❌ No | ✅ Yes |
Rate limits | 1000/min | 100/min |
Data persistence | 7 days | Permanent |
Webhook retries | 3 attempts | 8 attempts |
Debug info | ✅ Included | ❌ Not included |
Test cards | ✅ Work | ❌ Rejected |
Sandbox-Only Features
- Test data reset API
- Webhook testing endpoint
- Transaction simulation
- Time manipulation for testing
- Debug mode responses
Ready for Production?
Once you've completed all test scenarios, you're ready to go live!
Next Step: Go Live
Follow our comprehensive Going Live guide for a smooth production launch.
View Going Live Checklist
Troubleshooting Test Issues
Common Problems
Test payments not working
- Verify sandbox API key
- Check test card number format
- Ensure future expiry date
- Verify amount triggers
Webhooks not received
- Check webhook URL is public
- Verify signature validation
- Check firewall rules
- Review webhook logs
Unexpected test results
- Check sandbox status page
- Verify test data format
- Review API version
- Check for sandbox resets
Support for Testing
Need help with testing?
- Documentation: API Reference
- Test Dashboard: sandbox.moneybag.com.bd
- Support Email: support@moneybag.com.bd
- Status Page: status.moneybag.com.bd