LocalPay
Open-source Razorpay API emulator — test payments offline with no keys, no ngrok, every edge case one click away
Overview
LocalPay is a free, open-source server that behaves like the Razorpay API on your own machine. Apps keep using the official Razorpay SDK and checkout code, pointed at a local URL, and LocalPay creates orders and payments, captures and refunds them, sends signed webhooks to localhost and shows everything in a dashboard.
Problem
Testing Razorpay integrations needs an account, API keys, internet access and a tunnel like ngrok just to receive webhooks — and it's hard to reproduce failures like UPI timeouts, bank downtime or duplicate webhooks.
Solution
A deterministic local model of Razorpay's public API with a test checkout popup where each button is an outcome, webhook fault injection (duplicates, out-of-order, delays, missing signatures) and time travel so refunds, renewals and settlements run in seconds.
Architecture
- 1Local API server compatible with the official Razorpay SDKs (Node shim, Python base_url option)
- 2Test checkout.js popup with scenario buttons: pay, insufficient funds, bank down, UPI timeout, authorize only
- 3Signed webhook delivery to localhost with retries, replay and fault injection
- 4Dashboard and clock control to fast-forward time
- 5Runs in CI with no secrets
Technical Challenges
- Matching Razorpay's response and webhook shapes closely enough that real integration code runs unchanged.
- Making failure scenarios deterministic and repeatable for CI.
Results
- One command to start: npx localpay.
- Published on NPM under the Apache-2.0 license.
- Never moves money — no bank, card network or NPCI behind it, only a model of the public API.