NOT-RAZORPAYX
==========
A simple and reliable Node.js package for automating payment process.
Getting Started with razorpayX
-
sign up, account activation and KYC verification in razorpayx and make payouts. Steps to create your first payout:
- Create a Contact
- Add a Fund Account to a contact
- Create a Payout
Benefits
- Does only one thing and does it well. Only the Contact, Fund Account and Payout API methods are implemented.
- Good error handling:
- Only "2xx" and "3xx" responses from razorpay are considered successful.
- Tested and reliable. Includes test suite.
Synopsis
Start by creating a client object, and then call the createContact
, createAccount
, createPayout
method depending on your needs.
let NotPayout = client = NotPayout // Give razorpay the details and let it construct the payment for you. await client
The methody can be handled in 2 ways (Promises) or (async/await)
- Promises wayclient
- async/await waytryvar payout_details = await clientconsole;catch errorconsole;
Installation
npm install not-razorpayx --save
The module has one primary export:
createClient()
You'll probably only be using this method. It takes an options object with the following properties:
`key` - your Razorpayx key .
`secret` - your Razorpayx secret.
To create your razorpayX account. Check RazorpayX to be sure the region you are in is supported.
let NotPayout = client = NotPayout
-
Steps to follow.
- Create a Contact
- Add a Fund Account to a contact
- Create a Payout
Contact Methods
- There are several methods involves in Contacts module:
- CreateContact()
- updateContact()
- getContacts()
- enableContact()
- disableContact()
// Create new contactclient// Update Contact Detailsclient// Get all contacts.client// Get get single contact.let contact_id = 'cont_E3sSZ2ewjKGmcK'client;// Activate Contactclient// Deactivate Contactclient
CreateContact
receives an options object with the following properties:
`name` - string (required). User name to create the contact.
`email` - string. Email address of the contact.
`contact` - string. Phone number of the contact.
`type` - String. Available options are ['vendor', 'customer', 'employee', 'self']
`reference_id` - String. User-generated reference for the contact, This field can have a maximum length of 40 characters.
`notes` - Notes you can enter for the contact for future reference. This is a key-value pair Eg:{"note-key": "Beam me up Scotty"}
Fund Accounts Methods
- There are several methods involves in Fund Account module:
- createAccount()
- getFundAccounts()
- enableAccount()
- disableAccount()
// create new Fund accountclient// Get all Fund Accounts.client// Get single Fund Account Details.client// Activate Accountclient// Deactivate Accountclient
CreateAccount
receives an options object with the following properties:
For bank_account
`accountHolderName` - string (required). Name of account holder as per bank records. For example,Gaurav Kumar.
`ifsc` - string (required).IFSC for the account number. For example,HDFC0000053.
`account_number` - string (required). Beneficiary account number. For example, '765432123456789'.
For vpa
`vpaAddress` - string (required) The virtual payment address. For example, ragavrvd@upi.
For card
`cardHolderName` - string (required). Name of the credit card holder. For example,ragav rvd.
`cardNumber` - string (required). Beneficiary credit card number. For example, 765432123456789.
Payout Methods
- There are several methods involves in Payout module:
- createPayout()
- getSinglePayout()
- getPayouts()
- cancelPayout()
// create new Payoutclient// Get All Payouts.// client.getPayouts({// account_number:'7878780080316316'// })// Get get single Payout Details.client// Cancel the queued payout.client
CreatePayout
receives an options object with the following properties:
`account_number` - string (required). This is the business account from which the payout is to be made. For example, 7878780080316316.
`fund_account_id` - string (required). The unique ID linked to a fund account. For example, fa_00000000000001.
`amount` - integer (required). The amount, in paise, to be transferred from the business account to the contact's fund account. For example, if you want to transfer ₹100, pass 10000 against this parameter. The minimum value that can be passed is 100.
`currency` - string (required). The currency in which the payout is being made. In this case it is INR.
`mode` - string (required). The mode to be used to create the payout ['NEFT', 'RTGS', 'IMPS', 'IFT', 'UPI']. The payout modes are case sensitive. When creating payouts using APIs, ensure payout modes are entered in upper case.
`purpose` - string (required). The purpose of the payout that is being created.
`queue_if_low_balance` - boolean (optional). Represents that you want a payout to be queued if there is insufficient balance in your business account. If you want a payout to be queued when your business account has insufficient balance pass true, else pass false.
`reference_id` - string (optional). You can use this field to store your own transaction ID, if any. This field can have a maximum length of 40 characters.
`narration` - string (optional). This is a custom note that also appears on the bank statement. This field can have a maximum length of 30 characters. Allowed characters are: a-z, A-Z, 0-9 and space.
`notes` - (optional) 'object' Eg:{"note-key": "Beam me up Scotty"}
Request & Response
The request you made in this method transports your message to the razorpayx service.
If razzorpayx returns an HTTP status code that's less than 200
or greater than or equal to 400, we will catch with an error
object that is a direct translation of the error razorpayx provides.
See Error Handling section below for details on the structure of returned errors.
Check for errors returned since a 400 status is not uncommon.
The data
returned in the callback is the HTTP body returned by razorpayx as json object.
See the Razorpayx API Response docs for details.
Error Handling
Example error response:
- If you miss to send the required field values for any request yo will get the following error response.