SandPay
Open-source emulator of 15 payment gateways — Razorpay, PhonePe, Cashfree, PayU, Paytm, CCAvenue, BillDesk, Stripe, PayPal and more — on localhost
Overview
SandPay is a free, open-source server that behaves like 15 payment gateways on your own machine: Razorpay, PhonePe, Cashfree, PayU, Paytm, CCAvenue, Easebuzz, Instamojo, Juspay, Pine Labs Plural, Zaakpay, BillDesk, Airpay, Stripe and PayPal. Apps keep their real SDKs and HTTP calls and only change the host; SandPay answers in each gateway's own request format, signing scheme and webhook signature, and shows everything in one dashboard. It grew out of LocalPay, my Razorpay-only emulator.
Problem
Most Indian businesses run two or three payment gateways, and the bugs live in the gaps: webhooks that arrive twice or out of order, payments stuck in pending, a gateway that goes down during a sale. Testing that against real sandboxes needs accounts, keys, tunnels and luck, and you cannot make a sandbox fail on demand.
Solution
One event-sourced payment engine with a plug-in per gateway, so every gateway shares the same model of orders, payments, refunds and settlements while speaking its own wire format. A hosted checkout covers every payment method and outcome; chaos presets, webhook faults and an outage switch break things on purpose; time travel runs refunds, renewals and settlements in seconds.
Architecture
- 1Event-sourced core engine with a provider plug-in per gateway (15 packages): routes, auth, errors, serializers and webhook signing
- 2Each gateway's own crypto: PhonePe O-Bearer tokens, PayU SHA-512 hashes, CCAvenue AES forms, BillDesk HS256 JWS bodies, Stripe-Signature, PayPal OAuth and Orders v2
- 3Recurring payments: PhonePe Autopay with NPCI's 24-hour pre-debit notice, Cashfree subscriptions, PayU standing instructions, Paytm subscriptions; payment links on four gateways
- 4Chaos engine: per-order presets, API faults, duplicate/late/unsigned webhooks, and gateway outage mode (up, degraded, down)
- 5Cross-gateway compatibility suite that drives every gateway through its own API and checks they agree on one payment model
- 6Dashboard (React), hosted checkout (Preact, CSP-strict), Node and Python SDK shims, a Postman collection and an OpenAPI spec
Technical Challenges
- Sharing URL space: Stripe's /v1 overlaps Razorpay's, so requests are routed by the API key in the Authorization header; Juspay's paths collide with dashboard routes and live under a prefix.
- Modelling merchant-initiated mandate debits deterministically, with outcomes chosen by amount, so tests need no customer.
- Keeping fifteen different signature schemes verifiable end to end with each gateway's published algorithm.
Results
- Version 0.1.0 released on GitHub (30 Nov 2026) with installable CLI and SDK-shim packages.
- 984 automated tests; the compatibility suite passes 75/75 checks (5 scenarios × 15 gateways).
- A failover example proves a router survives a gateway outage by retrying and moving the payment to the next gateway.
- Refuses live credentials and never moves real money; Apache-2.0.