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

@squaredr/paykit-razorpay

v1.0.0

Published

Razorpay adapter for @squaredr/paykit — unified payment SDK

Readme

@squaredr/paykit-razorpay

Razorpay adapter for @squaredr/paykit.

Install

npm install @squaredr/paykit @squaredr/paykit-razorpay razorpay

Usage

import { UnifiedPayments } from '@squaredr/paykit';
import '@squaredr/paykit-razorpay';

const payments = new UnifiedPayments({
  provider: 'razorpay',
  credentials: {
    keyId: process.env.RZP_KEY_ID,
    keySecret: process.env.RZP_KEY_SECRET,
  },
});

How Razorpay maps to the unified API

Razorpay uses an order-based flow, which differs from Stripe's intent-based approach:

  1. charges.create() creates a Razorpay Order
  2. Your frontend opens Razorpay Checkout with the order ID
  3. Customer pays in the Checkout modal
  4. charges.retrieve('pay_xxx') fetches the resulting Payment

Supported operations

Charges

Maps to Razorpay Orders (create) and Payments (retrieve/capture).

// Create an order (returns status: 'pending')
const charge = await payments.charges.create({
  amount: 50000, // INR 500.00 in paise
  currency: 'INR',
  description: 'Order #42',
});
// charge.id → 'order_xxx'

// After frontend checkout, retrieve the payment
const payment = await payments.charges.retrieve('pay_xxx');
// payment.status → 'succeeded'

// Capture an authorized payment
await payments.charges.capture('pay_xxx', { amount: 50000 });

// List orders
const { data, hasMore } = await payments.charges.list({ limit: 10 });

Refunds

const refund = await payments.refunds.create({
  chargeId: 'pay_xxx', // payment ID, not order ID
  amount: 20000, // partial refund
});

Customers

const customer = await payments.customers.create({
  email: '[email protected]',
  name: 'Rahul',
  phone: '+919876543210',
});

await payments.customers.update('cust_xxx', { name: 'Rahul S' });

Note: Razorpay does not support deleting customers. Calling customers.delete() throws an error.

Payment methods

Razorpay handles payment methods through its Checkout frontend, not via API. All paymentMethods.* operations throw NotSupportedError.

import { NotSupportedError } from '@squaredr/paykit';

try {
  await payments.paymentMethods.create({ type: 'card' });
} catch (err) {
  if (err instanceof NotSupportedError) {
    // Expected — use Razorpay Checkout instead
  }
}

Subscriptions

Creates a Razorpay Plan + Subscription in one call.

const sub = await payments.subscriptions.create({
  customer: 'cust_xxx',
  amount: 99900, // INR 999.00
  currency: 'INR',
  interval: 'month', // day | week | month | year
});

await payments.subscriptions.cancel('sub_xxx');
await payments.subscriptions.cancel('sub_xxx', { cancelAtPeriodEnd: true });

Webhooks

// Verify signature (HMAC-SHA256)
const valid = payments.webhooks.verify(rawBody, headers, webhookSecret);

// Parse event
const event = payments.webhooks.parse(rawBody, headers, webhookSecret);
// event.type → 'charge.succeeded' | 'charge.failed' | 'refund.created' | ...

Required header: x-razorpay-signature

Credentials

| Key | Description | |-----|-------------| | keyId | Razorpay Key ID (rzp_live_... or rzp_test_...) | | keySecret | Razorpay Key Secret |

Capabilities

| Capability | Supported | |-----------|-----------| | charges | Yes | | authAndCapture | Yes | | refunds | Yes | | partialRefunds | Yes | | subscriptions | Yes | | savedPaymentMethods | No | | hostedCheckout | Yes | | webhooks | Yes | | multiCurrency | Yes | | threeDS | Yes |

License

MIT