S
ShadhinPay Docs

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:

EnvironmentBase URL
Sandboxhttps://sandbox.shadhinpay.com/api/v1
Productionhttps://api.shadhinpay.com/api/v1

Test Credentials

Create sandbox credentials in your dashboard:

  1. Go to SettingsAPI Keys
  2. Click Generate Sandbox Keys
  3. 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 NumberScenario
8801711111111Payment succeeds immediately
8801722222222Payment succeeds after 30 seconds
8801733333333Payment fails (insufficient balance)
8801744444444Payment fails (wrong PIN)
8801755555555Payment cancelled by user
8801766666666Payment times out

Test Amounts

Specific amounts trigger special behaviors:

Amount (BDT)Behavior
Any amountNormal flow
999Triggers server error (500)
998Triggers timeout
997Triggers 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 immediately

Failed 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/webhook

Testing 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 payment

Testing 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.

On this page