1.0.2 • Published 1 year ago

waitnpay-nodejs v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Installing

Package manager

Using npm:

$ npm install waitnpay-nodejs

Example

const WaitNPay = require("waitnpay-nodejs");

// Make a request to get Payment Token
async function getPaymentToken() {
  try {
    const response = await WaitNPay.generateToken({
      mid: "<YOUR MERCHANT ID>",
      amount: "",
      currency: "INR",
      order_number: "",
      customer_phone_number: "",
      customer_email: "",
      api_key: "<YOUR API KEY>",
      encryption_key: "<YOUR ENCRYPTION KEY>",
      description: "",
      payment_type: "S",
      customer_name: "",
      add_field1: "",
      add_field2: "",
      add_field3: "",
      add_field4: "",
      add_field5: "",
      return_url: "<RETURN URL>",
    });
    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

// Now submit a form to the following url with the retrieved payload and mid
// URL: https://app.waitnpay.com/WNPApp/waitNPayRequest
// form-data: {payload: response.data.payload, mid: response.data.mid}

// To decrypt the response use the following on the return url you provided
async function decryptResponse() {
  try {
    const response = await WaitNPay.checkResponse({
      payload: "<PAYLOAD FROM RESPONSE>",
      key: "<YOUR ENCRYPTION KEY>",
    });
    console.log(response);
  } catch (error) {
    console.error(error);
  }
}
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago