stackpicks.dev
Back to gallery
razorpay/razorpay-node preview
razorpay
razorpay/

razorpay-node

Razorpay node.js bindings

Stars
237
Forks
126
Watchers
237
Open issues
126
JavaScriptMIT master Updated 1 week ago~0 stars/day lifetime
Editor's take

The Indian payment stack. UPI, cards, wallets, EMI, subscriptions. INR-native so you avoid currency-conversion headaches. Mandatory if you are charging Indian customers. Better domestic rates than Stripe India.

Use this if

You are charging Indian customers — this is the default, not a choice.

Skip if

You serve only international customers — use Stripe.

Payments & Billing
Quick install
# Install via npm / pnpm / bun:
pnpm add razorpay-node
# or
npm install razorpay-node

Inferred from JavaScript · always double-check against the official README below.

README — rendered from razorpay/razorpay-node

Razorpay Node SDK

npm

Official nodejs library for Razorpay API.

Read up here for getting started and understanding the payment flow with Razorpay: https://docs.razorpay.com/docs/getting-started

Installation

npm i razorpay

Documentation

Documentation of Razorpay's API and their usage is available at https://docs.razorpay.com

Basic Usage

Instantiate the razorpay instance with key_id & key_secret. You can obtain the keys from the dashboard app (https://dashboard.razorpay.com/#/app/keys)

const Razorpay = require('razorpay');

var instance = new Razorpay({
  key_id: 'YOUR_KEY_ID',
  key_secret: 'YOUR_KEY_SECRET',
});

Using Access Token

Instantiate the razorpay instance with access_token. The access_token can be obtained only in case if you are a platform partner. For more information, refer page - https://razorpay.com/docs/partners/platform/.

const Razorpay = require('razorpay');

var instance = new Razorpay({
  "oauthToken": "ACCESS_TOKEN"
})

x The resources can be accessed via the instance. All the methods invocations follows the namespaced signature

// API signature
// {razorpayInstance}.{resourceName}.{methodName}(resourceId [, params])

// example
instance.payments.fetch(paymentId);

Every resource method returns a promise.

instance.payments
  .all({
    from: '2016-08-01',
    to: '2016-08-20',
  })
  .then(response => {
    // handle success
  })
  .catch(error => {
    // handle error
  });

If you want to use callbacks instead of promises, every resource method will accept a callback function as a last parameter. The callback functions will behave as Error First Callbacks

instance.payments.all(
  {
    from: '2016-08-01',
    to: '2016-08-20',
  },
  (error, response) => {
    if (error) {
      // handle error
    } else {
      // handle success
    }
  }
);

Supported Resources


Development

npm install

Testing

npm test

Release

  1. Switch to master branch. Make sure you have the latest changes in the local master
  2. Update the CHANGELOG.md & bump the version in package.json
  3. Commit
  4. Tag the release & push to Github
  5. Create a release on GitHub using the website with more details about the release
  6. Publish to npm with npm publish command

Licence

MIT Licensed. See LICENSE.txt for more details

Live data via GitHub REST API · Cached 30 min · Created 17 Apr 2015
razorpay/razorpay-node — Live preview — StackPicks