Troubleshooting Guide
Step-by-step debugging help for common Moneybag integration issues
Troubleshooting Guide
This guide helps you diagnose and resolve common issues with Moneybag integration.
Quick Diagnostics Checklist
Before diving into specific issues, run through this checklist:
Initial Checks
- ✓ Using correct API endpoint (sandbox vs production)?
- ✓ API key included in request headers?
- ✓ Request using HTTPS (required for production)?
- ✓ All required parameters included?
- ✓ Valid JSON format in request body?
- ✓ Server time synchronized (for signatures)?
Authentication Issues
Error: 401 Unauthorized
Symptoms:
{
"error": "Unauthorized",
"message": "Invalid API key"
}
Solutions:
-
Verify API Key Format
# Correct header format X-Merchant-API-Key: YOUR_API_KEY # Common mistakes Authorization: Bearer YOUR_API_KEY # Wrong! API-Key: YOUR_API_KEY # Wrong!
-
Check Environment Mismatch
- Sandbox key with production URL → Will fail
- Production key with sandbox URL → Will fail
// Correct matching const API_KEY = process.env.SANDBOX_API_KEY; const API_URL = 'https://sandbox.api.moneybag.com.bd';
-
Verify Key Status
- Log into dashboard
- Check if key is active
- Regenerate if necessary
Error: 403 Forbidden
Symptoms:
{
"error": "Forbidden",
"message": "IP not whitelisted"
}
Solutions:
- Add your server IP to whitelist in dashboard
- Check if using proxy/CDN (use origin IP)
- Verify IP hasn't changed (dynamic IP issues)
Payment Processing Issues
Payment Page Not Loading
Debug Steps:
-
Check Browser Console
// Open browser console (F12) // Look for errors like: // - CORS errors // - Mixed content warnings // - JavaScript errors
-
Verify Domain Whitelist
- Dashboard → Settings → Allowed Domains
- Add your domain (without https://)
- Include both www and non-www versions
-
Check Required Parameters
// Minimum required fields { "order_id": "unique_order_123", "order_amount": 100.00, "currency": "BDT", "success_url": "https://yoursite.com/success", "cancel_url": "https://yoursite.com/cancel", "fail_url": "https://yoursite.com/fail" }
Payment Stuck in Processing
Common Causes:
-
Webhook Not Responding
- Your webhook must return HTTP 200
- Check server logs for incoming webhooks
- Verify webhook URL is correct
-
Network Timeout
// Increase timeout for payment verification $client = new Client([ 'timeout' => 30, // 30 seconds 'connect_timeout' => 10 ]);
-
Session Expired
- Payment sessions expire after 30 minutes
- Implement session refresh logic
Webhook Issues
Webhooks Not Received
Diagnostic Steps:
-
Test Webhook Endpoint
# Test your webhook endpoint directly curl -X POST https://yoursite.com/webhook \ -H "Content-Type: application/json" \ -d '{"test": "data"}'
-
Check Firewall/Security
- Whitelist Moneybag IPs:
103.XXX.XXX.XXX/24
- Disable rate limiting for webhook endpoint
- Check WAF rules (Cloudflare, etc.)
- Whitelist Moneybag IPs:
-
Verify URL Format
✓ https://yoursite.com/webhook ✗ http://yoursite.com/webhook (no HTTPS) ✗ https://localhost/webhook (not public) ✗ https://192.168.1.1/webhook (private IP)
Webhook Signature Verification Failing
Debug Code:
function verifyWebhookSignature($payload, $signature, $secret) {
// Common mistake: using wrong encoding
$calculated = hash_hmac('sha256', $payload, $secret);
// Debug output
error_log("Received signature: " . $signature);
error_log("Calculated signature: " . $calculated);
error_log("Payload: " . $payload);
return hash_equals($calculated, $signature);
}
Common Issues:
- Using wrong secret key
- Modifying payload before verification
- Encoding/decoding issues
- Time sync problems
API Response Errors
Error: 400 Bad Request
Common Causes:
-
Invalid JSON
// Wrong - trailing comma { "amount": 100, } // Correct { "amount": 100 }
-
Missing Required Fields Check API documentation for required fields per endpoint
-
Invalid Field Values
// Common validation errors { "amount": "100", // Should be number, not string "email": "invalid", // Invalid email format "phone": "123", // Invalid phone format }
Error: 422 Unprocessable Entity
Symptoms:
{
"error": "Validation failed",
"details": {
"amount": ["Amount must be greater than 10"],
"currency": ["Invalid currency code"]
}
}
Solutions:
- Check field validation rules
- Verify data types (string vs number)
- Check min/max limits
Error: 500 Internal Server Error
What to do:
- Retry with exponential backoff
- Check status.moneybag.com.bd
- Contact support with request ID
Testing Issues
Test Transactions Not Working
Sandbox Environment Checks:
-
Using Test Credentials
// Sandbox test card const testCard = { number: "4111111111111111", exp_month: 12, exp_year: 2025, cvv: "123" };
-
Test Amount Triggers
100.00 → Success 200.00 → Insufficient funds 300.00 → Card declined 400.00 → Network error
-
Reset Test Data
- Sandbox data resets weekly
- Clear browser cache/cookies
- Try incognito mode
Performance Issues
Slow API Response
Optimization Tips:
-
Implement Caching
// Cache verification responses const cache = new Map(); async function verifyPayment(transactionId) { if (cache.has(transactionId)) { return cache.get(transactionId); } const result = await api.verifyPayment(transactionId); cache.set(transactionId, result); return result; }
-
Use Connection Pooling
// Reuse HTTP connections const agent = new https.Agent({ keepAlive: true, maxSockets: 10 });
-
Implement Retry Logic
async function apiCallWithRetry(fn, maxRetries = 3) { for (let i = 0; i < maxRetries; i++) { try { return await fn(); } catch (error) { if (i === maxRetries - 1) throw error; await sleep(Math.pow(2, i) * 1000); // Exponential backoff } } }
Mobile SDK Issues
iOS Integration Problems
Common Issues:
- Info.plist not updated with required permissions
- ATS (App Transport Security) blocking HTTP
- Certificate pinning issues
Solutions:
<!-- Info.plist -->
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>moneybag.com.bd</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
Android Integration Problems
Common Issues:
- ProGuard obfuscating SDK classes
- Network security config issues
- Missing permissions
Solutions:
// ProGuard rules (add to proguard-rules.pro)
-keep class com.moneybag.** { *; }
-keepclassmembers class com.moneybag.** { *; }
Debug Tools & Commands
cURL Debug Commands
# Test API connectivity
curl -I https://api.moneybag.com.bd/health
# Verbose output for debugging
curl -v -X POST https://sandbox.api.moneybag.com.bd/api/v2/payments/checkout \
-H "X-Merchant-API-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d @payment.json
# Test webhook endpoint
curl -X POST https://yoursite.com/webhook \
-H "X-Webhook-Signature: test_signature" \
-d '{"event":"payment.success","data":{}}'
Browser Console Commands
// Check if API is reachable
fetch('https://api.moneybag.com.bd/health')
.then(r => console.log('API Status:', r.status))
.catch(e => console.error('API Error:', e));
// Debug payment form
console.log('Form data:', new FormData(document.getElementById('payment-form')));
Getting Help
If you're still experiencing issues after following this guide:
-
Collect Debug Information:
- Request/Response headers
- Error messages
- Transaction IDs
- Timestamps
-
Check Resources:
-
Contact Support:
- Email: support@moneybag.com.bd
- Include debug information
- Provide steps to reproduce
Common Error Codes Reference
Code | Description | Solution |
---|---|---|
401 | Unauthorized | Check API key |
403 | Forbidden | Verify permissions/IP whitelist |
404 | Not Found | Check endpoint URL |
422 | Validation Error | Fix request parameters |
429 | Rate Limited | Implement backoff |
500 | Server Error | Retry or contact support |
502 | Bad Gateway | Temporary issue, retry |
503 | Service Unavailable | Check status page |
Prevention Tips
Best Practices
- 📊 Implement comprehensive logging
- 🔄 Use idempotency keys for payments
- ⏱️ Set appropriate timeouts
- 🔐 Validate webhook signatures
- 📈 Monitor error rates
- 🧪 Test edge cases in sandbox
- 📝 Keep API keys secure
- 🔄 Implement retry with backoff