Moneybag

Sandbox Testing

Test your Moneybag integration safely in our sandbox environment

Sandbox Testing

The Moneybag sandbox environment provides a safe space to test your payment integration without processing real transactions. This guide covers everything you need to know about sandbox testing.


Sandbox Overview

Sandbox Environment

All transactions in sandbox are simulated. No real money is processed. Perfect for testing your integration safely.

Key Features

  • Full API Access: All production endpoints available
  • Test Credentials: Pre-configured test cards and accounts
  • Simulated Responses: Realistic payment flows
  • No Real Money: Completely safe testing environment
  • Higher Rate Limits: More requests allowed for testing

Access Details


Creating a Sandbox Account

Step 1: Register

  1. Go to https://moneybag.com.bd/sandbox/
  2. Fill in your details
  3. Check your email for credentials

Step 2: Access Dashboard

  1. Log in to Sandbox Dashboard
  2. Navigate to Developer SettingsAPI Keys
  3. Generate your sandbox API key

Step 3: Store Your Credentials

# .env file
MONEYBAG_SANDBOX_API_KEY=sk_test_your_sandbox_key_here
MONEYBAG_SANDBOX_WEBHOOK_SECRET=whsec_test_your_secret_here

Test Cards

Use these test card numbers to simulate different scenarios:

Successful Payments

Card NumberBrandDescription
4111 1111 1111 1111VisaAlways approves
5555 5555 5555 4444MastercardAlways approves
3782 822463 10005AmexAlways approves
6011 1111 1111 1117DiscoverAlways approves

Card Details:

  • Expiry Date: Any future date (e.g., 12/25)
  • CVV: Any 3 digits (4 for Amex)
  • Name: Any name
  • ZIP/Postal Code: Any valid code

Failure Scenarios

Card NumberErrorDescription
4000 0000 0000 0002card_declinedGeneric decline
4000 0000 0000 9995insufficient_fundsNot enough balance
4000 0000 0000 0069expired_cardCard expired
4000 0000 0000 0127incorrect_cvcWrong CVV
4000 0000 0000 0119processing_errorProcessing error
4242 4242 4242 4241incorrect_numberInvalid card number

3D Secure Testing

Card NumberBehavior
4000 0000 0000 32203D Secure authentication required
4000 0000 0000 30633D Secure authentication required (will fail)
4000 0000 0000 30553D Secure supported but not required

Mobile Banking Test Accounts

bKash

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

Nagad

Phone NumberPINOTPResult
0180000000112345123456Success
0180000000212345123456Daily limit exceeded
0180000000312345123456Service unavailable
0180000000412345123456Transaction timeout

Rocket

Phone NumberPINOTPResult
0190000000112345123456Success
0190000000212345123456Network error
0190000000312345123456Invalid account

Amount-Based Testing

Use specific amounts to trigger different behaviors:

Amount (BDT)BehaviorUse Case
100.00Instant successHappy path testing
200.00Delayed success (10 seconds)Timeout handling
300.00Requires additional authentication3D Secure flow
400.00Random result (50% success rate)Retry logic
500.00Pending for 30 seconds then successAsync processing
666.66Always fails with insufficient fundsError handling
777.77Always fails with card declinedDecline handling
999.00Always fails with generic errorGeneric error handling
1234.56Triggers partial refund scenarioRefund testing

Testing Webhooks

Webhook Testing Endpoint

Trigger test webhooks to your endpoint:

curl -X POST https://sandbox.api.moneybag.com.bd/api/v2/webhooks/test \
  -H "X-Merchant-API-Key: YOUR_SANDBOX_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://yoursite.com/webhook",
    "event": "payment.success",
    "data": {
      "transaction_id": "TEST_TXN_123",
      "amount": 100.00
    }
  }'

Available Test Events

  • payment.success
  • payment.failed
  • payment.processing
  • payment.cancelled
  • refund.initiated
  • refund.completed
  • refund.failed

Local Testing with ngrok

Test webhooks on your local machine:

# Install ngrok
npm install -g ngrok

# Expose your local server
ngrok http 3000

# Use the ngrok URL as your webhook endpoint
# https://abc123.ngrok.io/webhook

Testing Different Scenarios

1. Successful Payment Flow

// Test successful payment
const testSuccessfulPayment = async () => {
  const checkout = await createCheckout({
    amount: 100.00, // Success amount
    card: '4111111111111111'
  });
  
  // Verify payment
  const verification = await verifyPayment(checkout.transaction_id);
  assert(verification.status === 'SUCCESS');
};

2. Failed Payment Handling

// Test payment failure
const testFailedPayment = async () => {
  const checkout = await createCheckout({
    amount: 999.00, // Failure amount
    card: '4000000000000002'
  });
  
  // Handle failure
  const verification = await verifyPayment(checkout.transaction_id);
  assert(verification.status === 'FAILED');
};

3. Refund Testing

// Test refund flow
const testRefund = async () => {
  // Create payment
  const payment = await createPayment(1234.56);
  
  // Process full refund
  const fullRefund = await processRefund(payment.transaction_id);
  assert(fullRefund.status === 'COMPLETED');
  
  // Process partial refund
  const partialRefund = await processRefund(payment.transaction_id, 500.00);
  assert(partialRefund.status === 'COMPLETED');
};

4. Webhook Testing

// Test webhook handling
const testWebhook = async () => {
  // Set up webhook endpoint
  app.post('/webhook', (req, res) => {
    const event = req.body;
    
    switch(event.type) {
      case 'payment.success':
        // Handle success
        break;
      case 'payment.failed':
        // Handle failure
        break;
    }
    
    res.status(200).send('OK');
  });
  
  // Trigger test webhook
  await triggerTestWebhook('payment.success');
};

Sandbox Limitations

What's Different from Production

FeatureSandboxProduction
Real Payments❌ No✅ Yes
Rate Limits100/min60/min
Data Persistence7 daysPermanent
Webhook Retries3 attempts8 attempts
API Response TimeMay be slowerOptimized
Test Credentials✅ Work❌ Blocked

Data Reset Policy

  • Sandbox data older than 7 days is automatically deleted
  • Test accounts remain active
  • API keys persist
  • Webhook configurations saved

Moving to Production

Once testing is complete:

Pre-Production Checklist

  • All test scenarios pass
  • Error handling implemented
  • Webhook integration tested
  • Security measures in place
  • Rate limiting implemented
  • Logging configured

Migration Steps

  1. Apply for Production Access

  2. Update Configuration

    // Change from sandbox
    const SANDBOX_URL = 'https://sandbox.api.moneybag.com.bd';
    const SANDBOX_KEY = 'sk_test_...';
    
    // To production
    const PRODUCTION_URL = 'https://api.moneybag.com.bd';
    const PRODUCTION_KEY = 'sk_live_...';
  3. Update Webhook URLs

    • Change webhook endpoints to production
    • Update webhook secrets
    • Test webhook signature verification
  4. Remove Test Code

    • Remove test card numbers
    • Remove debug logging
    • Update error messages

Troubleshooting Sandbox Issues

Common Problems

API Key Not Working

  • Verify you're using sandbox key (starts with sk_test_)
  • Check you're using sandbox URL
  • Ensure key is active in dashboard

Webhooks Not Received

  • Verify webhook URL is publicly accessible
  • Check webhook secret is correct
  • Ensure ngrok is running (for local testing)

Test Cards Rejected

  • Use correct test card numbers
  • Ensure future expiry date
  • Check amount triggers

Rate Limiting

  • Sandbox allows 100 requests/minute
  • Implement exponential backoff
  • Use webhook testing endpoint sparingly

Best Practices

  1. Test Edge Cases

    • Network timeouts
    • Invalid inputs
    • Duplicate requests
    • Race conditions
  2. Automate Testing

    // Automated test suite
    describe('Payment Integration', () => {
      it('handles successful payment', async () => {
        // Test implementation
      });
      
      it('handles payment failure', async () => {
        // Test implementation
      });
      
      it('processes refunds', async () => {
        // Test implementation
      });
    });
  3. Monitor Sandbox Usage

    • Track API calls
    • Monitor error rates
    • Review webhook failures
  4. Document Test Scenarios

    • Keep test cases updated
    • Document expected behaviors
    • Share with team

Support

Need help with sandbox testing?