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

razorpayx-sdk

v0.1.1

Published

Unofficial Node.js SDK for the RazorpayX API (Contacts, Fund Accounts, Payouts, Payout Links, Transactions, Account Validation, Balances) written in TypeScript.

Readme

razorpayx-sdk

An unofficial, dependency-free Node.js SDK for the RazorpayX API, written in TypeScript. It covers Contacts, Fund Accounts, Payouts (including the Composite API), Payout Links, Transactions, Account Validation, and Balances.

  • Zero runtime dependencies — uses the global fetch built into Node.js 18+.
  • Fully typed requests and responses.
  • Ships both ESM and CommonJS builds.
  • Throws a single RazorpayXError with the parsed Razorpay error payload on failure.

This is a community SDK and is not published or endorsed by Razorpay.

For a condensed API reference designed for LLMs/coding agents, see llms.md.

Install

npm install razorpayx-sdk

Quick start

import { RazorpayX } from "razorpayx-sdk";

const client = new RazorpayX({
  keyId: process.env.RAZORPAYX_KEY_ID!,
  keySecret: process.env.RAZORPAYX_KEY_SECRET!,
});

const contact = await client.contacts.create({
  name: "Gaurav Kumar",
  email: "[email protected]",
  contact: "9123456789",
  type: "employee",
});

const fundAccount = await client.fundAccounts.create({
  contact_id: contact.id,
  account_type: "bank_account",
  bank_account: {
    name: "Gaurav Kumar",
    ifsc: "HDFC0009107",
    account_number: "50100102283912",
  },
});

const payout = await client.payouts.create(
  {
    account_number: "7878780080316316",
    fund_account_id: fundAccount.id,
    amount: 100000, // in paise (₹1,000.00)
    currency: "INR",
    mode: "IMPS",
    purpose: "refund",
    queue_if_low_balance: true,
  },
  crypto.randomUUID(), // idempotency key, sent as X-Payout-Idempotency
);

CommonJS works the same way:

const { RazorpayX } = require("razorpayx-sdk");

Configuration

new RazorpayX({
  keyId: string,      // required — API Key ID
  keySecret: string,  // required — API Key Secret
  baseUrl?: string,    // default: "https://api.razorpay.com/v1/"
  timeout?: number,    // default: 30000 (ms)
});

Keys are read from wherever you choose to load them (e.g. process.env) — the SDK does not read environment variables itself.

Resources

Every method returns a Promise that resolves with the parsed JSON response, or rejects with a RazorpayXError.

Contacts

await client.contacts.create({ name, email, contact, type, reference_id, notes });
await client.contacts.fetch(contactId);
await client.contacts.update(contactId, { name, email, ... });
await client.contacts.activate(contactId);
await client.contacts.deactivate(contactId);
await client.contacts.all({ count, skip, active, ... });

Fund Accounts

await client.fundAccounts.create({
  contact_id,
  account_type: "bank_account", // or "vpa" | "card"
  bank_account: { name, ifsc, account_number },
});
await client.fundAccounts.fetch(fundAccountId);
await client.fundAccounts.activate(fundAccountId);
await client.fundAccounts.deactivate(fundAccountId);
await client.fundAccounts.all({ contact_id, count, skip });

Payouts

// Payout to an existing fund account
await client.payouts.create(
  { account_number, fund_account_id, amount, currency: "INR", mode, purpose },
  idempotencyKey, // optional, sent as X-Payout-Idempotency
);

// Composite API: create the contact + fund account and pay out in one call
await client.payouts.createComposite({
  account_number,
  amount,
  currency: "INR",
  mode: "UPI",
  purpose: "refund",
  fund_account: {
    account_type: "vpa",
    vpa: { address: "gaurav@exampleupi" },
    contact: { name: "Gaurav Kumar", type: "employee" },
  },
});

await client.payouts.fetch(payoutId);
await client.payouts.cancel(payoutId); // only payouts in the `queued` state can be cancelled
await client.payouts.all({ account_number, status, mode, count, skip });

Payout Links

await client.payoutLinks.create({
  account_number,
  contact: { name, contact, email }, // or { id: contactId }
  amount,
  currency: "INR",
  purpose: "refund",
});
await client.payoutLinks.fetch(payoutLinkId);
await client.payoutLinks.cancel(payoutLinkId);
await client.payoutLinks.all({ account_number, contact_id, count, skip });

Transactions

await client.transactions.all({ account_number, count, skip, from, to });
await client.transactions.fetch(transactionId);

Account Validation (Fund Account Validation)

await client.accountValidation.create({
  account_number,
  fund_account: { id: fundAccountId },
  amount: 100,
});
await client.accountValidation.fetch(validationId);
await client.accountValidation.all({ count, skip });

Balances

await client.balances.fetch({ account_number });

Error handling

API errors are thrown as a RazorpayXError, which carries the fields Razorpay returns in its error object:

import { RazorpayXError } from "razorpayx-sdk";

try {
  await client.payouts.create({ ... });
} catch (err) {
  if (err instanceof RazorpayXError) {
    console.error(err.statusCode, err.code, err.message, err.reason);
  } else {
    throw err;
  }
}

Development

npm install
npm run build       # bundle to dist/ (ESM + CJS + .d.ts)
npm test            # run the test suite
npm run typecheck
npm run lint

License

MIT