not-payouts-razorpayx
v1.0.0
Published
A package for make payment easy using razorpayx
Downloads
4
Maintainers
Readme
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 = require('not-razorpayx')
, client = NotPayout.configPayout({ key: 'key', secret: 'secret' })
// Give razorpay the details and let it construct the payment for you.
await client.createPayout({
account_number: '<account_number_created_in fund_account>',
details:{
fund_account_id: "fa_E2i8yMbO5rag3Es",
amount:10000,
currency:'INR',
mode:'NEFT',
purpose:'payout',
queue_if_low_balance: true,
reference_id:'ref1234',
narration:'NextOnTop HI Tech Soft Solution',
notes: { company: 'nextontop', processing: 'done' }
},
})
The methody can be handled in 2 ways (Promises) or (async/await)
- Promises way
client.createPayout() .then(data =>{ console.log(data) }) .catch(error => { console.log(error); })
- async/await way
try { var payout_details = await client.createPayout() console.log(payout_details); } catch (error) { console.log(error); }
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 = require('not-razorpayx')
, client = NotPayout.configPayout({ key: 'key', secret: 'secret' })
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 contact
client.createContact({
name: 'ragav rvd', // (mandatory) 'String'
email: '[email protected]', // (optional) 'String'
contact: '9677822758', // (optional) 'String'
type: 'customer', // (optional) 'String' ['vendor', 'customer', 'employee', 'self']
reference_id:'contact_1234', // (optional) 'String' Can have a maximum length of 40 characters.
notes: {} //(optional) 'object' Eg:{"note-key": "Beam me up Scotty"}
})
// Update Contact Details
client.updateContact({
id: 'cont_E3sSZ2ewjKGmcK', // (mandatory) The unique identifier linked to the contact.
//The details need to update
name: 'ragav',
email: '[email protected]',
contact: '9874563210',
})
// Get all contacts.
client.getContacts()
// Get get single contact.
let contact_id = 'cont_E3sSZ2ewjKGmcK'
client.getContacts(contact_id);
// Activate Contact
client.enableContact({ id: 'cont_E3sSZ2ewjKGmcK'})
// Deactivate Contact
client.disableContact({ id: 'cont_E3sSZ2ewjKGmcK'})
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 account
client.createAccount({
contact_id: 'cont_E3sSZ2ewjKGmcK', // (mandatory) 'String'
account_type: 'bank_account', // [bank_account, 'vpa', 'card']
details:{
// for bank_account type
accountHolderName:'ragav rvd', // (mandatory) 'String'
ifsc:'HDFC0000053', // (mandatory) 'String'
account_number:"765432123456789", // (mandatory) 'String'
// for vpa type
// vpaAddress:"[email protected]", // (mandatory) 'String'
// for the card type
// cardHolderName:"ragav rvd", (optional) 'String'
// cardNumber:"765432123456789" // (mandatory) 'String'
},
})
// Get all Fund Accounts.
client.getAccounts()
// Get single Fund Account Details.
client.getSingleAccount({id:'fa_E3sSZ2ewjKGmcK'})
// Activate Account
client.enableContact({ id: 'fa_E3sSZ2ewjKGmcK' })
// Deactivate Account
client.disableContact({ id: 'fa_E3sSZ2ewjKGmcK'})
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 Payout
client.createPayout({
account_number: '7878780080316316', //(mandatory) 'String' This is the business account from which the payout is to be made. For example, 7878780080316316.
details:{
fund_account_id: "fa_E2i8yPtL5Peb3Zs", //(mandatory) 'String' The unique ID linked to a fund account. For example, fa_00000000000001.
amount:1000, // (mandatory) 'Integer' The amount, in paise, to be transferred from the business account to the contact's fund account.The minimum value that can be passed is 100.
currency:'INR', //(mandatory) string.
mode:'NEFT', //(mandatory) 'String' ['NEFT', 'RTGS', 'IMPS', 'IFT', 'UPI']
purpose:'payout', // (mandatory) 'String' ['refund','cashback','payout','salary','utility bill','vendor bill']
queue_if_low_balance: true, // (mandatory) 'String'[true, false]
reference_id:'ref1234', // You can use this field to store your own transaction ID, if any. This field can have a maximum length of 40 characters.
narration:'NextOnTop HI Tech SoftSolution', // Data type string. 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"}
},
})
// Get All Payouts.
// client.getPayouts({
// account_number:'7878780080316316'
// })
// Get get single Payout Details.
client.getSinglePayout({id:'pout_E2iACAzvh9MwvC'})
// Cancel the queued payout.
client.cancelPayout({id:'pout_E2iACAzvh9MwvC'})
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.
{
"err_code": "BAD_REQUEST_ERROR",
"message": "No db records found."
}