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

razorpay-trigger

v0.1.0

Published

Trigger signed mock Razorpay webhooks against localhost. Like `stripe trigger`, for Razorpay.

Readme

rzp-cli

Trigger signed, realistic mock Razorpay webhooks against your local server. Like stripe trigger, but for Razorpay — no ngrok, no dashboard clicking, no real payments.

$ npx razorpay-trigger trigger payment.captured --url http://localhost:3000/webhooks/razorpay --secret dev_secret

→ payment.captured  pay_Kx9v2LqT8mRp4a  ₹500.00  upi
  POST http://localhost:3000/webhooks/razorpay
  x-razorpay-signature: 4f2a…c91e
✓ 200 OK  12 ms
  body: {"received":true}

The request carries a real X-Razorpay-Signature (hex HMAC-SHA256 of the raw body, keyed with your webhook secret) and an X-Razorpay-Event-Id, so your existing signature verification code runs unchanged.

Zero runtime dependencies.

Why

Razorpay's docs tell you to expose localhost with ngrok and trigger real test-mode events from the dashboard. That's slow, and it doesn't work in CI. This tool builds the webhook body locally, signs it the same way Razorpay does, and POSTs it to whatever URL you give it.

Install

npm i -g razorpay-trigger        # or: npx razorpay-trigger …

Requires Node 20+ to run. (Node 22.18+ to run the TypeScript source directly during development.)

Usage

rzp trigger <event> [options]
rzp events
rzp sign   --secret <s> [--file payload.json]
rzp verify --secret <s> --signature <sig> [--file payload.json]

Events

| Event | Contains | |---|---| | payment.authorized | payment | | payment.captured | payment | | payment.failed | payment | | order.paid | payment, order | | refund.created | refund, payment | | refund.processed | refund, payment | | refund.failed | refund, payment | | subscription.activated | subscription, payment | | subscription.charged | subscription, payment | | subscription.cancelled | subscription | | subscription.halted | subscription | | payment_link.paid | payment_link, payment, order |

Options

| Flag | Meaning | |---|---| | -u, --url | Where to POST | | -s, --secret | Webhook secret your app verifies with | | -a, --amount | Amount in paise (50000 = ₹500). Default 50000 | | -m, --method | upi (default), card, netbanking, wallet | | --currency | Default INR | | --email, --contact | Customer details | | --order-id, --payment-id | Use fixed IDs so your test can look them up | | --account-id | Value for account_id | | --set path=value | Override any field. Repeatable. Values parse as JSON when possible | | --dry-run | Print the request instead of sending | | --json | Print only the event JSON (pipe it anywhere) | | --timeout | Milliseconds, default 10000 |

Config

Flags win over environment variables, which win over .rzprc.json in the current directory:

export RZP_WEBHOOK_URL=http://localhost:3000/webhooks/razorpay
export RZP_WEBHOOK_SECRET=dev_secret
rzp trigger order.paid
// .rzprc.json  (git-ignore this)
{ "url": "http://localhost:3000/webhooks/razorpay", "secret": "dev_secret" }

Examples

# A ₹1,299 card payment for a specific order your test created
rzp trigger order.paid --amount 129900 --method card --order-id order_test123

# Tweak any field
rzp trigger payment.captured --set payload.payment.entity.notes.user_id=42 \
                             --set payload.payment.entity.vpa=someone@okaxis

# Generate a fixture for your test suite
rzp trigger refund.processed --json > test/fixtures/refund.processed.json

# Sign an existing payload (e.g. one you copied from the dashboard)
rzp sign --secret dev_secret --file payload.json

Verifying on your side

Whatever framework you use, verify the raw body bytes — never a parsed-then-re-stringified object.

// Express: capture the raw body
app.post("/webhooks/razorpay", express.raw({ type: "application/json" }), (req, res) => {
  const expected = crypto.createHmac("sha256", process.env.RZP_WEBHOOK_SECRET).update(req.body).digest("hex");
  const given = req.headers["x-razorpay-signature"];
  if (!crypto.timingSafeEqual(Buffer.from(expected, "hex"), Buffer.from(String(given), "hex"))) {
    return res.status(400).send("bad signature");
  }
  const event = JSON.parse(req.body);
  // …
  res.json({ received: true });
});

The official razorpay npm package exposes the same check as validateWebhookSignature(rawBody, signature, secret).

A zero-dependency receiver you can run right now is in examples/server.mjs.

In CI

- run: node server.js &
- run: npx razorpay-trigger trigger payment.captured --url http://localhost:3000/webhooks/razorpay --secret $RZP_WEBHOOK_SECRET

Exit codes: 0 on a 2xx response, 1 on non-2xx or connection failure, 2 on usage error.

Fidelity

Payloads follow the shapes in Razorpay's webhook documentation (envelope with entity, account_id, event, contains, payload, created_at; entity objects inside). They are approximations meant to exercise your handler, not a certified replica — if you need a field byte-exact, compare against a real test-mode webhook from your dashboard and use --set (or open a PR).

Roadmap

  • rzp listen — forward real test-mode webhooks to localhost through a relay
  • rzp replay <event_id> — re-send an event from your dashboard history
  • Cashfree and PhonePe event sets
  • Custom fixture files (--from payload.json)

Development

npm install
npm test          # runs the .ts tests directly on Node 22.18+
npm run build     # emits dist/

Disclaimer

Not affiliated with or endorsed by Razorpay. "Razorpay" is a trademark of Razorpay Software Private Limited.

MIT