Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

razorpay

razorpay296.6kMIT2.9.6TypeScript support: included

Official Node SDK for Razorpay API

razorpay, payments, node, nodejs, razorpay-node

readme

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

changelog

Changelog

2.9.6 - 2025-02-24

feat: Added support for access token based authentication mechanism

  • Added oauth APIs (getAuthURL, getAccessToken, refreshToken, revokeToken)
  • Added support for onboarding signature generation
  • Doc updated

2.9.5 - 2024-10-23

fix: Cancel subscription cancelAtCycleEnd now supports both boolean and 0/1 values as expected.

2.9.4 - 2024-05-17

fix: Resolve SSRF vulnerability in request handling feat: Added new API endpoints

  • Added support for addBankAccount, deleteBankAccount, requestEligibilityCheck & fetchEligibility on customer
  • Added support for Dispute
  • Added support for Document
  • Added support for viewRtoReview & editFulfillment on order
  • Added support for fetch all IINs Supporting native otps & fetch all IINs with business sub-type using all

2.9.3 - 2024-04-18

fix: Type definition for Product and Customer has been updated.

2.9.2 - 2023-08-16

chore: Changed Content-Type of all APIs from application/x-www-form-urlencoded to application/json

2.9.1 - 2023-07-18

fix: A bug in the “Create Payment Link” request has been fixed.

2.9.0 - 2023-06-30

feat: Added new API endpoints

  • Added account onboarding API create, fetch, edit, delete
  • Added stakeholders API create, fetch, fetchAll, edit
  • Added product configuration API requestProductConfiguration, fetch, edit, `fetchTnc
  • Added webhooks API create, fetch, fetchAll, edit, delete
  • Added Documents API uploadAccountDoc, fetchAccountDoc, uploadStakeholderDoc , fetchStakeholderDoc
  • Added token sharing API create, fetch, delete, processPaymentOnAlternatePAorPG

2.8.6 - 2023-02-22

feat(Typescript): add typescript definitions

  • TypeScript definitions for all modules and functions in the SDK.
  • Add comments throughout the codebase to improve readability and maintainability.
  • Add a type declarations file (*.d.ts) to provide better type checking and editor support for consumers of the SDK.

Overall, this update should provide a better developer experience for anyone using the SDK, by leveraging the power of TypeScript's static type checking and providing clearer documentation and comments throughout the codebase.

Note: This release is a patch of the previous release that includes an update to the razorpay.d.ts file

2.8.5 - 2023-02-22

feat(Typescript): add typescript definitions

  • TypeScript definitions for all modules and functions in the SDK.
  • Add comments throughout the codebase to improve readability and maintainability.
  • Add a type declarations file (*.d.ts) to provide better type checking and editor support for consumers of the SDK.

Overall, this update should provide a better developer experience for anyone using the SDK, by leveraging the power of TypeScript's static type checking and providing clearer documentation and comments throughout the codebase.

2.8.4 - 2022-11-21

2.8.3 - 2022-07-28

  • [Bugfix]: create order api
  • Updated Documentation

2.8.2 - 2022-06-29

  • Added Third party validation & Otp API for Payment (createUpi, validateVpa, otpGenerate, otpSubmit, otpResend)
  • Update Documention

2.8.1 - 2022-03-09

  • fix: passing fixed_amount boolean issue when creating qrcode
  • fix: passing partial_payment boolean issue when creating qrcode
  • fix: passing settle_full_balance boolean issue when creating settlments
  • fix: item create api
  • Added Card api
  • Updated Documention.

2.8.0 - 2021-11-21

  • Items end point API [#235]
  • QR code end point API [#228]
  • Update, create registration link,fetch details of a Pending Update, deleteOffer, cancel, pause and resume subscription API [#214]
  • addReceiver, allowedPayer and deleteAllowedPayer (Virtual Account) TPV API'S [#231]
  • paymentVerification ,fetchPaymentDowntimeById, fetchPaymentDowntime,fetchCardDetails, transfer,fetchTransfer, fetchRefund,fetchMultipleRefund,createPaymentJson ,createRecurringPayment & edit function (Payment) [#232]
  • Fetch all Addons [#219]
  • Fetch all Customers [#221]
  • Fund account end point API [#222]
  • Edit orders [#223]
  • Added edit, notifyBy (PaymentLink) [#225]
  • qrCode end point API [#228]
  • Edit refund [#229]
  • Settlements end point API [#230]

  • Added Signature verficiation [#232]

  • Update readme file [#233]

2.0.7 - 2021-08-20

  • Added new payment link end point in Api (#203).
  • Updated dependencies.

2.0.6 - 2020-01-28

  • fix: receipt is an optional param when creating orders (#118).
  • Updated dependencies.

2.0.5 - 2019-08-12

  • Added support for Order creation amount=0 + method=emandate.
  • Dependency updates.

2.0.4 - 2019-03-06

  • Added recipient_settlement_id parameter for Transfers.
  • Renamed "X-Razorpay-Header" to "X-Razorpay-Signature header" in the error message in validateWebhookSignature.
  • Added support for currency in capture method for Payments.

2.0.3 - 2018-11-13

  • Added support for Partner Auth.

2.0.2 - 2018-11-08

  • Added support for TypeScript.

2.0.1 - 2018-6-26

Fixed

  • Security Fixes

2.0.0 - 2018-6-14

Removed

  • Removed sending only specific parameters to orders api, every parameter will be sent as it is , validation is done on API.

Deprecated

  • Removing validations on SDK, all parameters will be sent as it is to all apis respectively

1.7.0 - 2018-2-20

Added

Deprecated

  • Deprecated sending only specific parameters to orders api , rest being ignored

1.6.0 - 2017-9-2017

Added

  • More api methods for Virtual Accounts
  • Plans API
  • Subscriptions API
  • Addons API

1.5.1 - 2017-9-12

Added

  • Added Invoices api
  • Invoices unit tests
  • Updated readme and wiki
  • Bumped the version to 1.5.0

1.4.0 - 2017-8-18

Added

  • Added virtual accounts api
  • Virtual Accounts unit tests
  • Added promise polyfill
  • Updated readme and wiki
  • Bumped the version to 1.4.0

1.3.0

  • [Feature] Support for Marketplace accounts transfers

1.2.1

  • [Bugfix] Don't assume undefined values as 0 in the requests

1.2.0

  • [Feature] Support for fetching order's payments

1.1.0

  • [Feature] Adds Customer & tokens support
  • [Tests] Adds test coverage

1.0.0

  • [Docs] Update readme.md
  • [Docs] Adds Changelog

0.0.1

  • Initial Release