A node wrapper library for Instamojo APIs.
npm install instamojo-nodejs
var Insta = require('instamojo-nodejs');
Insta.setKeys(API_KEY, AUTH_KEY);
- 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
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
Insta.seeAllLinks(function(error, response) {
if (error) {
// Some error
} else {
console.log(response);
}
});
Insta.getAllPaymentRequests(function(error, response) {
if (error) {
// Some error
} else {
console.log(response);
}
});
Insta.getPaymentRequestStatus("PAYMENT-REQUEST-ID", function(error, response) {
if (error) {
// Some error
} else {
console.log(response);
}
});
Insta.getPaymentDetails("PAYMENT-ID", function(error, response) {
if (error) {
// Some error
} else {
console.log(response);
}
});
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.
Insta.getRefundDetails("REFUND-ID", function(error, response) {
if (error) {
// Some error
} else {
// Refund status at response.refund.status
console.log(response);
}
});
Insta.getAllRefunds(function(error, response) {
if (error) {
// Some error
} else {
console.log(response);
}
});
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';
Add this line after setting your keys
Insta.isSandboxMode(true);
- Added get all refunds API
- Added payment details API
- Updated payment request details API
- Updated get all payment requests API
You can raise an issue in this repo or mail me at sidhant@hashexclude.com