Kkarthikshet.com
Open source · Payments & FintechApache license

SandPay

Open-source emulator of 15 payment gateways — Razorpay, PhonePe, Cashfree, PayU, Paytm, CCAvenue, BillDesk, Stripe, PayPal and more — for testing payments, webhooks, UPI AutoPay and outages offline.

GitHub starsLast commit
SandPay screenshot

Quick start

bash
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

Screenshots

SandPay screenshot

Every Indian payment gateway — plus Stripe and PayPal — on localhost. Test Razorpay, PhonePe, Cashfree, PayU, Paytm, CCAvenue, Easebuzz, Instamojo, Juspay, Pine Labs, Zaakpay, BillDesk, Airpay, Stripe and PayPal integrations offline: no keys, no ngrok, every payment method and every failure mode one click away.

CI Release License: Apache-2.0

Walkthrough: a coding agent starts SandPay, creates a Cashfree order, pays it on the hosted checkout, sees the signed webhook on the dashboard, takes Cashfree down so the router fails over to PhonePe, and runs the compatibility suite: 75 of 75 checks pass across 15 gateways

A coding agent tests a Cashfree checkout end to end: payment, webhook, an outage with failover, and the 15-gateway compatibility suite. Every frame is a real SandPay screen or real command output (recorded by scripts/record-walkthrough.js).

What is SandPay?

SandPay is a free, open-source server that behaves like 15 payment gateways on your own machine. Your app keeps its real SDK or HTTP calls and only changes the host:

Gateway Point your integration at Instead of
Razorpay http://127.0.0.1:4010 (+ /v1/checkout.js) api.razorpay.com
PhonePe PG v2 http://127.0.0.1:4010/apis/pg-sandbox api-preprod.phonepe.com/apis/pg-sandbox
Cashfree PG http://127.0.0.1:4010/pg sandbox.cashfree.com/pg
PayU India http://127.0.0.1:4010/_payment test.payu.in/_payment
Paytm PG http://127.0.0.1:4010 securegw-stage.paytm.in
CCAvenue http://127.0.0.1:4010 test.ccavenue.com, apitest.ccavenue.com
Easebuzz http://127.0.0.1:4010 testpay.easebuzz.in
Instamojo http://127.0.0.1:4010 test.instamojo.com
Juspay http://127.0.0.1:4010/juspay sandbox.juspay.in
Pine Labs Plural http://127.0.0.1:4010/api pluraluat.v2.pinepg.in/api
Zaakpay http://127.0.0.1:4010 zaakstaging.zaakpay.com
BillDesk (v1.2) http://127.0.0.1:4010 uat1.billdesk.com
Airpay http://127.0.0.1:4010 payments.airpay.co.in
Stripe http://127.0.0.1:4010/stripe (stripe-node: host only) api.stripe.com
PayPal http://127.0.0.1:4010 api-m.sandbox.paypal.com

Each gateway speaks its own wire format: PhonePe's O-Bearer tokens and SHA-256 callbacks, Cashfree's x-api-version headers and HMAC webhooks, PayU's SHA-512 form hashes, Paytm's AES checksums, CCAvenue's encrypted forms, BillDesk's JWS bodies, Stripe's form encoding and Stripe-Signature, PayPal's OAuth and Orders v2, Razorpay's signatures. One engine, one dashboard, one event log behind all of them. It never moves money and needs no account, no internet and no tunnel, so it runs in CI with no secrets.

Quickstart

Install the CLI from the latest release (Node 22+) and start it:

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

Or run it from a clone:

git clone https://github.com/karthikrshet/SandPay.git && cd SandPay
pnpm install && pnpm build
pnpm sandpay start --webhook http://127.0.0.1:3000/webhooks

The npm package (npx sandpay) is not published yet.

The banner prints every gateway's base URL, the demo credentials and a dashboard link. Demo credentials are public on purpose; they only work against SandPay:

Gateway Credentials
Razorpay rzp_test_SandPayDemo001 / sandpay_demo_secret
PhonePe client SANDPAYTEST_CLIENT / sandpay_phonepe_secret, version 1
Cashfree TEST_SANDPAY_APP_ID / cfsk_ma_test_sandpay_secret
PayU key sp_test_key, salt sp_test_salt
Paytm MID SANDPAYTEST0000001, key SandPayPaytmKey1
CCAvenue merchant SANDPAYTEST1, access code AVSP00SANDPAYTEST, working key SANDPAYCCAVENUEWORKINGKEY0000001
Easebuzz key SANDPAYTESTKEY, salt SANDPAYTESTSALT
Instamojo test_sandpay_client / test_sandpay_secret, salt sandpay_instamojo_salt
Juspay API key SANDPAYTESTAPIKEY, merchant sandpay_test
Pine Labs Plural sandpay-test-client / sandpay_plural_secret
Zaakpay sandpaytestmerchant0000000000001 / sandpay_zaakpay_secret_key
BillDesk mercid SANDPAYUAT, client sandpayuat, secret sandpay_billdesk_hmac_secret
Airpay mercid SANDPAYTEST, sandpayuser / sandpaypass, secret sandpay_airpay_secret
Stripe sk_test_sandpay_demo_key, webhook secret whsec_sandpay_demo
PayPal SandPaySandboxClientId / SandPaySandboxSecret

Run only the gateways you use with -g phonepe,cashfree. Full guides: docs/gateways.

What you can test

  • Every payment method. UPI (intent, collect, QR), credit/debit/prepaid cards on Visa, MasterCard, RuPay, Amex and Diners, netbanking, wallets, card EMI, cardless EMI, pay later, bank transfer (NEFT/RTGS/IMPS) and app payments, each reported with the gateway's own names.
  • Every outcome. Success, pending, insufficient funds, bank down, wrong UPI PIN, customer cancel, authorize-only, late authorization, partial and failed refunds, disputes.
  • Recurring payments and links. UPI AutoPay / e-mandates on PhonePe (with NPCI's 24-hour pre-debit notice), Cashfree, PayU and Paytm, Razorpay subscriptions, and payment links on Razorpay, Cashfree, PayU and Paytm.
  • Gateway outages. Take any gateway down or make it flaky from the dashboard or --outage cashfree=down, and prove your failover: see examples/failover.
  • Settlement reports. Per-gateway CSV/JSON of every captured payment and refund with fee, tax, net, settlement id and UTR.
  • Chaos. Per order: stuck in pending, success arriving late, duplicate webhooks, missing webhooks, redirect-beats-webhook races, status API timeouts and dropped connections, double payments, failing refunds. Server-wide: 429s, 500s, connection resets, latency, out-of-order and unsigned webhooks. See docs/chaos.md.
  • A payment simulator. --odds success=0.8,pending=0.1,failure=0.1 makes "Auto" payments and UPI collect requests follow those odds, reproducibly with --seed.
  • Webhooks for real. Signed exactly like each gateway signs them, delivered to localhost, retried with backoff, replayable from the dashboard or a recorded session.
  • Time travel. sandpay time advance 3d runs refunds, renewals, expiries and settlements in seconds.

One integration, 15 gateways: the compatibility suite

Most Indian apps run two or three gateways. They should agree on what happened to a payment. sandpay compat drives every enabled gateway through its own public API with the same customer stories and checks each one ends up in the same state:

$ sandpay compat
scenario  razorpay  phonepe   cashfree  payu      paytm     ccavenue  easebuzz  instamojo …  stripe    paypal
success   pass      pass      pass      pass      pass      pass      pass      pass      …  pass      pass
declined  pass      pass      pass      pass      pass      pass      pass      pass      …  pass      pass
retry     pass      pass      pass      pass      pass      pass      pass      pass      …  pass      pass
pending   pass      pass      pass      pass      pass      pass      pass      pass      …  pass      pass
refund    pass      pass      pass      pass      pass      pass      pass      pass      …  pass      pass

75/75 passed

The same normalisers (@sandpay/compat) map each gateway's states onto one model (created → pending → paid | failed, refunds pending → processed | failed), which is a good template for your own multi-gateway code.

Dashboard

The SandPay dashboard's Gateways page: a navy sidebar and one card per gateway with its base URL and demo credentials

Orders and payments from every gateway in one place, filterable by gateway, with a chaos switch per order, buttons to make the bank say yes or no to a pending payment, a webhook log with replay, per-gateway webhook targets, the payment simulator and time travel.

CLI

sandpay [start] [options]        start the server (default command)
sandpay compat [-g list]         check every gateway agrees on the same payment stories
sandpay status | reset | time advance <duration>
sandpay scenario list | run <file|id>
sandpay replay <session.jsonl> --webhook <url>

Useful start options: -g/--gateways, --odds, --webhook <url> --webhook-gateway <g>, --fault reset=0.05, --outage phonepe=down, --seed, --persist, --refund-delay, --merchant-name. Run sandpay help for all of them.

Developer kit

  • SDK shims: @sandpay/shim-node points the Razorpay SDK at SandPay and gives every gateway's base URL (sandpayUrl('cashfree')) and stripe-node host options (stripeOptions()); a dependency-free Python module does the same for Python SDKs.
  • Postman: docs/postman has requests for all 15 gateways, with signatures computed in pre-request scripts.
  • OpenAPI: docs/openapi describes SandPay's own control API (outages, chaos, time travel, reports), kept in step with the code by a test.
  • Examples: Express, FastAPI, Django, Next.js, multi-gateway webhooks and failover routing.

In CI

- uses: karthikrshet/SandPay/action@main
  with:
    package: https://github.com/karthikrshet/SandPay/releases/download/v0.1.0/sandpay-0.1.0.tgz
- run: npm test   # your tests talk to http://127.0.0.1:4010

How it is built

flowchart LR
  subgraph SandPay
    RZ[Razorpay /v1] --> E
    PP[PhonePe /apis/pg-sandbox] --> E
    CF[Cashfree /pg] --> E
    PU[PayU /_payment] --> E
    PT[Paytm /theia] --> E
    MORE[CCAvenue, Easebuzz, Instamojo,<br/>Juspay, Pine Labs, Zaakpay,<br/>BillDesk, Airpay, Stripe, PayPal] --> E
    H[Hosted pay page<br/>all methods, chaos] --> E
    E[(Engine<br/>state machines + event log)] --> D[Webhook dispatcher<br/>per-gateway signing, retries, chaos]
    E --> UI[Dashboard]
  end
  D -- signed webhooks --> App[Your app]
Package What it does
core entities, state machines, event log, clock, ids, gateways, payment methods
gateway-kit hashing, rupee parsing, outcomes, chaos presets, simulator, outages, mandates, links, Fastify hooks
upi VPA rules, upi:// intents, QR codes
hosted the CSP-strict hosted pay page shared by every gateway except Razorpay
provider-* (15 packages) each gateway's routes, auth, errors, serializers and webhook format
webhooks dispatcher: routing by gateway, retries, replay, faults, SSRF guard
server wires everything into one Fastify app plus the dashboard API
compat the cross-gateway compatibility suite
dashboard, checkout, cli, shims, scenarios UI, Razorpay checkout.js, sandpay command, Node SDK shim, YAML scenarios

Design decisions are in docs/adr. Endpoint coverage per gateway is in docs/compat.md.

Quality

Strict TypeScript, ESLint with architecture rules, and about 1,000 tests: unit tests next to every module, full checkout flows per gateway, signature round-trips against each gateway's published algorithm, end-to-end webhook verification and the compatibility suite on all 15 gateways. pnpm lint && pnpm typecheck && pnpm test.

Security and safety

  • Binds to 127.0.0.1 only unless you pass --allow-public and a dashboard password.
  • Refuses live-looking credentials for every gateway (rzp_live_, sk_live_, non-TEST Cashfree apps, non-staging Paytm MIDs, prod PayU keys, PhonePe ids without TEST/SANDBOX/UAT, non-sandbox PayPal apps, and so on).
  • Signatures are compared in constant time; secrets never reach logs.
  • Hosted pages use a strict CSP with no inline scripts, escape every value and redirect only to http(s) URLs.
  • Webhook targets pass an SSRF guard (no cloud metadata or link-local addresses).

Report vulnerabilities as described in SECURITY.md.

Status

SandPay grew out of LocalPay, a Razorpay emulator. Razorpay is the most complete gateway; the other 14 are written from their public documentation and marked partial until compared with recorded sandbox traffic (Airpay is modelled on its PHP kit, and PayPal webhooks use HMAC instead of RSA — see their guides). Always run your integration against each gateway's real sandbox before going live.

Disclaimer

SandPay is an independent open-source project. It is not affiliated with, endorsed by or connected to Razorpay, PhonePe, Cashfree, PayU, Paytm, CCAvenue, Easebuzz, Instamojo, Juspay, Pine Labs, Zaakpay (MobiKwik), BillDesk, Airpay, Stripe or PayPal. Their names are used only to describe API compatibility. SandPay never processes real payments.

License

Apache-2.0