Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

razorpay

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

razorpay

Official Node SDK for Razorpay API

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
53K
increased by4.46%
Maintainers
1
Weekly downloads
 
Created
Source

Razorpay Node SDK

npm version

Official nodejs bindings 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 --save

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)

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

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'
}, function(error, response) => {
  if (error) {
    // handle error
  } else {
    // handle success
  }
})

Resources

* indicates mandatory field

Payments

instance.payments.all({from, to, count, skip})

Fetches payments list.

NameTypeDescription
fromtimestamptimestamp after which the payments were created
totimestamptimestamp before which the payments were created
countintegernumber of payments to fetch (default: 10)
skipintegernumber of payments to be skipped (default: 0)
instance.payments.fetch(payment_id)

Retrieves a particular payment.

Parameters:

NameTypeDescription
payment_id*stringId of the payment to be retrieved
instance.payments.capture(payment_id, amount)

Capture a payment.

Parameters:

NameTypeDescription
paymentId*stringId of the payment to capture
amount*integerThe amount to be captured (should be equal to the authorized amount, in paise)
instance.payments.refund(payment_id, {amount, notes})

Refund a payment.

Parameters:

NameTypeDescription
payment_id*stringId of the payment to refund
amountintegerThe amount to be refunded (in paise)
notesobjectA key-value pair

--

Refunds

instance.refunds.all({from, to, count, skip, payment_id})

Fetches refunds list. If payment_id is passed, refunds of that particular payment is fetched

Parameters:

NameTypeDescription
payment_idstringThe payment id whose refunds are to be fetched
fromtimestamptimestamp after which the payments were created
totimestamptimestamp before which the payments were created
countintegernumber of payments to fetch (default: 10)
skipbooleannumber of payments to be skipped (default: 0)
instance.refunds.fetch(refund_id, {payment_id})

Fetches a refund.

Parameters:

NameTypeDescription
refund_id*stringID of the refund to be retrieved
payment_idstringThe id of the payment whose refund is to be retrieved

--

Orders

instance.orders.create({amount, currency, receipt, payment_capture, notes})

Create an order in razorpay

Parameters:

NameTypeDescription
amount*integerAmount of the order to be paid
currencystringCurrency of the order. Currently only INR is supported.
receipt*stringYour system order reference id.
payment_capturebooleanWhether the payment should be captured automatically or not. Default false
notesobjectA key-value pair
instance.orders.all({from, to, count, skip, authorized, receipt})

Fetches orders list

Parameters

NameTypeDescription
fromtimestamptimestamp after which the payments were created
totimestamptimestamp before which the payments were created
countintegernumber of payments to fetch (default: 10)
skipintegernumber of payments to be skipped (default: 0)
authorizedbooleanOrders for which payments are currently in authorized state.
receiptstringOrders with the provided value for receipt.
instance.orders.fetch(order_id)

Fetches a particular order

Parameters

NameTypeDescription
order_id*stringThe id of the order to be retrieved

Development

npm install

Run your tests using 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. LICENSE file added to repo.

Keywords

FAQs

Package last updated on 13 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc