A node.js module, which provides an object oriented wrapper for the Instamojo REST API.
This library is built to support version 1.1
of the Instamojo API.
Instamojo API documentation can be found here
Install with the node package manager npm:
$ npm install pay-instamojo
const InstamojoApi = require('pay-instamojo').instamojo;
const instamojo = new InstamojoApi({
host: <instamojo-host>,
apiKey: <instamojo-x-api-key>,
authToken: <instamojo-x-auth-token>
});
/* For getRequestLists input is not required, hence first parameter is null in this call. */
instamojo.getRequestLists(null, (error, body) => {
console.log('RESPONSE: ', error, body);
});
let input = {
allowRepeatedPayment: <your-choice>, // true or false (boolean)
amount: <amount-to-pay>, // e.g., 10
buyerName: <buyer-name>,
purpose: <purpose-of-payment>,
redirectUrl: <redirectUrl-if-any>,
phone: <phone-number>, // 10 digit valid phone number if any
sendSMS: <your-choice>, // true or false (if true then phone is mandatory)
email: <email-id-to-send-payment-link>, // valid email if any
sendEmail: <your-choice>, // true or false (if true then email is mandatory)
webhook: <webhook-url>
}
instamojo.createRequest(input, function (error, body) {
console.log('RESPONSE:', error, body)
})
let input = {
paymentRequestId: <payment-request-id>
}
instamojo.getPaymentRequestById(input, function (error, body) {
console.log('RESPONSE:', error, body)
})
Find input parameter values definition here
let input = {
paymentId: <payment-id>, // Id you got as payment acknowledgment
type: <code-to-identify-reason-for-this>,
refundAmount: <paid-amount>, // not mandatory (if preset then valid amount)
body: <text-explaining-refund> // not mandatory
}
instamojo.createRefund(input, function (error, body) {
console.log('RESPONSE:', error, body)
})
/* For getListOfRefunds input is not required, hence first parameter is null in this call. */
instamojo.getListOfRefunds(null, (error, body) => {
console.log('RESPONSE: ', error, body);
});
let input = {
refundId: <refund-id>
}
instamojo.getRefundDetailsById(input, function (error, body) {
console.log('RESPONSE:', error, body)
})
let input = {
paymentId: <refund-id>
}
instamojo.getPaymentDetailsById(input, function (error, body) {
console.log('RESPONSE:', error, body)
})
let input = {
paymentRequestId: <payment-request-id>
}
instamojo.disablePaymentRequest(input, function (error, body) {
console.log('RESPONSE:', error, body)
})
let input = {
paymentRequestId: <payment-request-id>
}
instamojo.enablePaymentRequest(input, function (error, body) {
console.log('RESPONSE:', error, body)
})
InstamojoApi options:
host<string>
: The hostname for instamojoapiKey<string>
: Instamojo X-Api-KeyauthToken<string>
: Instamojo X-Auth-Token
- Get List of All Payment Requests
- Create Payment Request
- Get Payment Request By Id
- Create Refund
- Get List Of Refunds
- Get Refund Details By Id
- Get Payment Details By Id
- Disable Payment Request By Id
- Enable Payment Request By Id
- 1.0.3 getListOfRefunds, getRefundDetailsById, getPaymentDetailsById, disablePaymentRequest, enablePaymentRequest functions added
- 1.0.2 get payment request by id, create refund function added
- 1.0.1 request dependency missing (added in package.json)
- 1.0.0 Initial version