npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@premprakashgupta/razorpay-mock-client

v1.0.2

Published

Pixel-perfect Razorpay Checkout Mock for Frontend

Downloads

224

Readme

Razorpay Mock Studio ⚡

🛑 DISCLAIMER: UNOFFICIAL COMMUNITY TOOL This package is not affiliated with, endorsed by, or maintained by Razorpay Software Private Limited. It is an independent, unofficial mock server built by the community for local testing purposes. All trademarks belong to their respective owners.

A high-fidelity, local mock engine and dashboard for testing Razorpay integrations without exposing real credentials or interacting with the live banking network.

🚀 Getting Started

If you install the mock studio via npm in your project, starting the mock server is extremely simple!

Installation

Run the following command in your project directory:

npm install -g @premprakashgupta/razorpay-mock-server
npm install @premprakashgupta/razorpay-mock-client --save

Starting the Server

Once installed, you can start the mock server anywhere inside your project by running:

npx @premprakashgupta/razorpay-mock-server

Volatile CI/CD Mode: If you are running the mock server in a CI pipeline (e.g. GitHub Actions) and want to avoid writing to a local db.json file, use the --memory-only flag:

npx @premprakashgupta/razorpay-mock-server --memory-only

Alternatively, you can just add a simple script to your package.json to make it easier to launch alongside your dev server:

{
  "scripts": {
    "dev": "your-dev-command",
    "mock-studio": "razorpay-mock-studio"
  }
}

The Mock Studio dashboard will instantly be available at: http://localhost:3001/studio


⚡ Instant Project Scaffolding

Don't want to manually integrate into an existing app? Both packages contain built-in boilerplate generators!

1. Generating a Backend Playground

If you want a ready-to-run Mock Backend folder, run:

npx @premprakashgupta/razorpay-mock-server init

This instantly scaffolds a razorpay-mock-backend/ folder complete with configuration wrappers.

2. Generating a Frontend React Boilerplate

If you want to test the checkout UI without setting up a React app manually:

npx @premprakashgupta/razorpay-mock-client init

This drops a razorpay-mock-frontend/ folder containing standard Checkout.js and Checkout.tsx boilerplate implementations!


🛠️ Integration Guide

1. Update API Keys

Go to the API Keys tab in the Mock Studio and copy your key_id and key_secret. Use these safely in your local .env file instead of your real Razorpay credentials.

2. Connect Your Backend (Node.js SDK)

When creating orders on your server, simply inject the x-razorpay-mock-host header to route requests to the Mock Studio instead of the live Razorpay API:

const Razorpay = require('razorpay');

const rzp = new Razorpay({
  key_id: process.env.RAZORPAY_KEY_ID,    // From Mock Studio
  key_secret: process.env.RAZORPAY_SECRET, // From Mock Studio
  headers: {
    'x-razorpay-mock-host': 'http://localhost:3001'
  }
});

// Orders will now hit your local Mock DB natively
const order = await rzp.orders.create({ amount: 500, currency: 'INR' });

// You can also create Plans and Subscriptions!
const plan = await rzp.plans.create({ period: 'monthly', interval: 1, item: { name: 'Pro', amount: 50000, currency: 'INR' } });
const sub = await rzp.subscriptions.create({ plan_id: plan.id, total_count: 12 });

// You can process Refunds against captured Order IDs
const refund = await rzp.payments.refund("pay_MOCK1234", { amount: 500 });

3. Connect Your Frontend Client

Replace the official Razorpay script/hook with the mock client in your frontend app (React, Vue, plain JS, etc.):

import { useRazorpay } from "@premprakashgupta/razorpay-mock-client";

// The rest of your code remains identical!
const Razorpay = useRazorpay();

// Works for both one-time orders and subscriptions natively:
const rzp = new Razorpay({
   key: options.key,
   order_id: options.order_id, // OR subscription_id: options.subscription_id
   handler: function (response) {
      console.log(response.razorpay_payment_id);
   }
   // ...
});
rzp.open();


🔁 Webhooks & HMAC Verification

Mock Studio implements the exact same HMAC SHA-256 signature algorithm used by Razorpay for production webhook deliveries.

  1. Open the Mock Studio Webhooks tab.
  2. Click Add Webhook and provide your local endpoint (e.g., http://localhost:3000/api/webhook) and a secret.
  3. Every time a mock payment is successful, Mock Studio will fire a payment.captured event to your endpoint.
  4. Your application can verify the x-razorpay-signature HTTP header exactly as it would in production!

💡 Express.js Pro Tip: If your backend uses Express, ensure your webhook route is placed above the express.json() middleware, or that you use express.raw({type: 'application/json'}) for this specific route.


🗄️ Database & Storage

Razorpay Mock Studio uses the native Node.js SQLite engine for production-grade stability and zero external dependencies.

  • Persistence: By default, it creates a hidden .razorpay-mock folder in your project directory to store the SQLite database. This hidden folder ensures that tools like Next.js, Vite, and Webpack do not trigger infinite re-build loops when the database is updated.
  • Requirements: This tool requires Node.js 22.5.0 or higher (recommended Node 24+) to utilize the built-in SQLite features.

💡 Troubleshooting & Performance

If you are running a very large project (e.g., Next.js 15 with Turbopack) and encounter a "Fatal process out of memory" error in your frontend, this is a known issue with the memory overhead of modern build tools on newer Node versions.

Recommended Fix: Increase your Node.js heap limit by setting the following environment variable before starting your dev server:

# Windows (PowerShell)
$env:NODE_OPTIONS="--max-old-space-size=4096"

# Mac/Linux
export NODE_OPTIONS="--max-old-space-size=4096"