Testing & Sandbox
Test your ShadhinPay integration before going live
Testing & Sandbox Guide
Test your integration thoroughly using our sandbox environment before processing real payments.
Sandbox Environment
Use the sandbox environment for all testing:
| Environment | Base URL |
|---|---|
| Sandbox | https://sandbox.shadhinpay.com/api/v1 |
| Production | https://api.shadhinpay.com/api/v1 |
Test Credentials
Create sandbox credentials in your dashboard:
- Go to Settings → API Keys
- Click Generate Sandbox Keys
- Use keys prefixed with
_test_
// Sandbox configuration
const config = {
baseUrl: 'https://sandbox.shadhinpay.com/api/v1',
clientId: 'cl_test_xxx',
businessId: 'bus_test_xxx',
secretKey: 'sk_test_xxx',
};Test Phone Numbers
Use these phone numbers to simulate different scenarios:
| Phone Number | Scenario |
|---|---|
8801711111111 | Payment succeeds immediately |
8801722222222 | Payment succeeds after 30 seconds |
8801733333333 | Payment fails (insufficient balance) |
8801744444444 | Payment fails (wrong PIN) |
8801755555555 | Payment cancelled by user |
8801766666666 | Payment times out |
Test Amounts
Specific amounts trigger special behaviors:
| Amount (BDT) | Behavior |
|---|---|
| Any amount | Normal flow |
999 | Triggers server error (500) |
998 | Triggers timeout |
997 | Triggers rate limit error |
Testing Payment Flows
Successful Payment
const payment = await createPayment({
amount: 1000,
currency: 'BDT',
customer_phone: '8801711111111', // Success phone
callback_url: 'https://yoursite.com/webhook',
});
// Redirect user to payment_url
// Payment will complete immediatelyFailed Payment
const payment = await createPayment({
amount: 1000,
currency: 'BDT',
customer_phone: '8801733333333', // Fail phone
callback_url: 'https://yoursite.com/webhook',
});
// Payment will fail with "insufficient balance"Testing Webhooks
Trigger Test Webhooks
Use our webhook testing endpoint:
curl -X POST https://sandbox.shadhinpay.com/api/v1/test/webhook \
-H "Client-Id: your_test_client_id" \
-H "Business-Id: your_test_business_id" \
-H "Secret-Key: your_test_secret_key" \
-H "Content-Type: application/json" \
-d '{
"event": "payment.completed",
"callback_url": "https://yoursite.com/webhook",
"data": {
"payment_id": "SP_TEST_123",
"amount": 1000
}
}'Local Testing with ngrok
# Start your local server
npm run dev
# In another terminal
ngrok http 3000
# Use the ngrok URL for callback_url
# Example: https://abc123.ngrok.io/webhookTesting Invoices
Test invoice creation and payment:
const invoice = await createInvoice({
customer_name: 'Test Customer',
customer_email: 'test@example.com',
customer_phone: '8801711111111',
items: [
{ description: 'Test Item', quantity: 1, unit_price: 1000 }
],
});
// Visit the payment_url to test paymentTesting Refunds
Test refund processing:
// First create and complete a payment
const payment = await createPayment({
amount: 1000,
customer_phone: '8801711111111',
// ...
});
// Wait for payment to complete, then refund
const refund = await refundPayment(payment.payment_id, {
amount: 500, // Partial refund
reason: 'Test refund',
});Going Live Checklist
Before switching to production:
- All test scenarios pass
- Webhook signature verification works
- Error handling is robust
- Idempotency is implemented
- Logging is in place
- SSL certificate is valid
- Production credentials are secured
- Rate limiting is handled
Switching to Production
Update your configuration:
// Production configuration
const config = {
baseUrl: 'https://api.shadhinpay.com/api/v1',
clientId: process.env.SHADHINPAY_CLIENT_ID, // cl_live_xxx
businessId: process.env.SHADHINPAY_BUSINESS_ID, // bus_live_xxx
secretKey: process.env.SHADHINPAY_SECRET_KEY, // sk_live_xxx
};Never use test credentials in production or vice versa. They are completely separate environments.