How to Test Razorpay, PhonePe, Cashfree, Stripe and PayPal Integrations Offline
2026-11-30 · 6 min read
Most Indian businesses that take payments online run more than one gateway: Razorpay for cards, PhonePe for UPI, Cashfree or PayU as a backup, Stripe or PayPal for international customers. The bugs live in the gaps between them. A webhook arrives twice. A UPI payment says "pending" for an hour and then succeeds. One gateway goes down on the biggest sale day of the year.
You can't make a real sandbox do any of that on demand. So I built SandPay: a free, open-source server that behaves like 15 payment gateways on your own machine.
Which gateways SandPay emulates
Thirteen Indian gateways and two global ones:
- Razorpay, PhonePe (PG v2), Cashfree, PayU and Paytm
- CCAvenue, Easebuzz, Instamojo, Juspay, Pine Labs Plural, Zaakpay (MobiKwik), BillDesk (v1.2 JOSE) and Airpay
- Stripe (PaymentIntents, Checkout Sessions, Refunds) and PayPal (Orders v2)
Each one speaks its own wire format: PhonePe's O-Bearer tokens, PayU's SHA-512 form hashes, CCAvenue's AES-encrypted forms, BillDesk's HS256-signed JWS bodies, Stripe's form encoding and Stripe-Signature webhooks, PayPal's OAuth tokens. That means your integration code doesn't change. You keep the official SDK and only point it at http://127.0.0.1:4010.
Starting it
SandPay needs Node.js 22. Install the CLI from the GitHub release and start it with a webhook URL:
npm install -g https://github.com/karthikrshet/SandPay/releases/download/v0.1.0/sandpay-0.1.0.tgz
sandpay --webhook http://127.0.0.1:3000/webhooks
The banner prints every gateway's local base URL and demo credentials. Then, for example, a Cashfree order:
curl -X POST http://127.0.0.1:4010/pg/orders \
-H 'x-client-id: TEST_SANDPAY_APP_ID' \
-H 'x-client-secret: cfsk_ma_test_sandpay_secret' \
-H 'x-api-version: 2023-08-01' -H 'content-type: application/json' \
-d '{"order_id":"ORD-1","order_amount":499,"order_currency":"INR","customer_details":{"customer_id":"c1","customer_phone":"9876543210"}}'
The response has a payment_session_id; open the hosted checkout with it, pick a payment method and an outcome, and a signed PAYMENT_SUCCESS_WEBHOOK lands on your server, exactly as Cashfree would send it.
What you can break on purpose
This is the part real sandboxes can't give you:
- Every outcome. Success, decline, insufficient funds, wrong UPI PIN, bank down, payments stuck in pending that resolve later, payments that are authorized late.
- Webhook chaos. Duplicates, out-of-order delivery, delays, missing signatures, and one-click replay from the dashboard.
- Gateway outages. Switch any gateway to
degraded(half the calls fail, the rest are slow) ordown(every call returns 503) from the dashboard or with--outage cashfree=down. - Time travel. Refunds, subscription renewals and settlements run in seconds instead of days.
- Recurring payments. UPI AutoPay on PhonePe with NPCI's 24-hour pre-debit notice enforced, Cashfree subscriptions, PayU standing instructions and Paytm subscriptions. Debits pick their outcome by amount, so tests need no customer.
Proving failover works
The repository includes a failover router: try Cashfree, fall back to PhonePe, then Razorpay. It retries network errors, timeouts and 5xx responses with backoff, opens a circuit breaker after repeated failures, and refuses to hide 4xx errors (those are bugs in your request). Its tests take gateways down with outage mode and check that the payment still goes through.
One integration, 15 gateways
SandPay's compatibility suite drives every gateway through its own API — create an order, pay, decline, retry, leave a payment pending, refund — and checks that all 15 agree on what happened. Today it passes 75 of 75 checks. Behind it are 984 automated tests.
What it is not
SandPay never moves money and refuses live-looking credentials. Its request and response shapes come from each gateway's public documentation, and the compatibility notes say where it is approximate. Always run a final round against each gateway's real sandbox before going live. SandPay is an independent project, not affiliated with any gateway it emulates.
The code is on GitHub under Apache-2.0. If a gateway has burned you in production, open an issue with the failure mode and I'll add it.