instamojo-nodejs

0.0.5 • Public • Published

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 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


Submit issues

You can raise an issue in this repo or mail me at sidhant@hashexclude.com

Package Sidebar

Install

npm i instamojo-nodejs

Weekly Downloads

699

Version

0.0.5

License

ISC

Last publish

Collaborators

  • sidhantpanda