Moneybag
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 NumberBrandResult3D Secure
4111 1111 1111 1111VisaSuccessNo
5555 5555 5555 4444MastercardSuccessNo
3782 822463 10005AmexSuccessNo
4000 0000 0000 3220VisaSuccessRequired

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 NumberError CodeDescription
4000 0000 0000 0002CARD_DECLINEDGeneric decline
4000 0000 0000 9995INSUFFICIENT_FUNDSNot enough balance
4000 0000 0000 0069EXPIRED_CARDCard expired
4000 0000 0000 0127INVALID_CVVIncorrect CVV
4000 0000 0000 0119PROCESSING_ERRORBank error
4000 0000 0000 3055FRAUD_SUSPECTEDFraud detection triggered

Mobile Banking Test Accounts

bKash Testing

Phone NumberPINOTPResult
0170000000112345123456Success
0170000000212345123456Insufficient funds
0170000000312345123456Account blocked
0170000000412345000000Invalid OTP

Nagad Testing

Phone NumberPINOTPResult
0180000000112345123456Success
0180000000212345123456Daily limit exceeded
0180000000312345123456Service unavailable

Rocket Testing

Phone NumberPINOTPResult
0190000000112345123456Success
0190000000212345123456Transaction timeout
0190000000312345123456Network error

Amount-Based Test Triggers

Use specific amounts to trigger different scenarios:

Amount (BDT)ScenarioUse Case
100.00Instant successHappy path testing
200.00Payment fails after 10 secondsTimeout handling
300.00Requires 3D SecureAuthentication flow
400.00Random failure (50% chance)Retry logic testing
500.00Pending for 30 secondsStatus polling
999.00Always failsError handling
1234.56Partial refund scenarioRefund 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

FeatureSandboxProduction
Real payments❌ No✅ Yes
Rate limits1000/min100/min
Data persistence7 daysPermanent
Webhook retries3 attempts8 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?