instamojo-nodejs
v0.0.5
Published
Instamojo API Wrapper
Downloads
1,713
Maintainers
Readme
Instamojo NodeJs Wrapper
A node wrapper library for Instamojo APIs.
npm install instamojo-nodejs
Include and set keys
var Insta = require('instamojo-nodejs');
Insta.setKeys(API_KEY, AUTH_KEY);
APIs Available
- Create a payment request
- See all payment links
- Get all payments
- See payment request details
- See payment details
- Initiate refund
- Get refund details
- Get all refunds
- Set sanbox mode
Create new payment request
var data = new Insta.PaymentData();
data.purpose = "Test"; // REQUIRED
data.amount = 9; // REQUIRED
data.setRedirectUrl(REDIRECT_URL);
Insta.createPayment(data, function(error, response) {
if (error) {
// some error
} else {
// Payment redirection link at response.payment_request.longurl
console.log(response);
}
});
You can set additional data parameters. See here
See all payment links
Insta.seeAllLinks(function(error, response) {
if (error) {
// Some error
} else {
console.log(response);
}
});
Get all payment requests
Insta.getAllPaymentRequests(function(error, response) {
if (error) {
// Some error
} else {
console.log(response);
}
});
Get payment status for a particular payment request id
Insta.getPaymentRequestStatus("PAYMENT-REQUEST-ID", function(error, response) {
if (error) {
// Some error
} else {
console.log(response);
}
});
Get payment details for a particular payment id and payment request id
Insta.getPaymentDetails("PAYMENT-REQUEST-ID", "PAYMENT-ID", function(error, response) {
if (error) {
// Some error
} else {
console.log(response);
}
});
Initiate refund
var refund = new Insta.RefundRequest();
refund.payment_id = ''; // This is the payment_id, NOT payment_request_id
refund.type = ''; // Available : ['RFD', 'TNR', 'QFL', 'QNR', 'EWN', 'TAN', 'PTH']
refund.body = ''; // Reason for refund
refund.setRefundAmount(8); // Optional, if you want to refund partial amount
Insta.createRefund(refund, function(error, response) {
console.log(response);
});
Details on refund types here.
Get refund status for a refund id
Insta.getRefundDetails("REFUND-ID", function(error, response) {
if (error) {
// Some error
} else {
// Refund status at response.refund.status
console.log(response);
}
});
Get all refunds
Insta.getAllRefunds(function(error, response) {
if (error) {
// Some error
} else {
console.log(response);
}
});
Additional Payment Data
data.currency = 'INR';
data.buyer_name = '<buyer name>';
data.email = '<buyer email>';
data.phone = 1234567890;
data.send_sms = 'False';
data.send_email = 'False';
data.allow_repeated_payments = 'False';
data.webhook = 'Your endpoint to capture POST data from a payment';
data.redirect_url = 'Your endpoint where instamojo redirects user to after payment';
Set sandbox mode
Add this line after setting your keys
Insta.isSandboxMode(true);
Changes in v0.0.4
Changes in v0.0.3
- Added get all refunds API
- Added payment details API
- Updated payment request details API
- Updated get all payment requests API
Submit issues
You can raise an issue in this repo or mail me at [email protected]