0.0.23 • Published 2 months ago

tap-payment-popupjs v0.0.23

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

TAP-Inlinejs

Popup Library for loading TAP's payment checkout gateway. It makes it easy to accept payments from a web application and to create custom, secure payment experiences for merchant apps and websites

Requirements

node >= 12.0.0
npm >= 6.0.0

Introduction

This documentation provides an overview of the TouchandPay Payment Popup (TAPPaymentPop) JavaScript library that facilitates payment integration with the TAP payment gateway. It explains how to use the library, describes its main features and provides an example of how to integrate it with a web page.

Getting Started

To use the TAPPaymentPop JavaScript library, you need to first include the following script tag in your HTML code:

<!-- Production -->

<script src="https://unpkg.com/tap-payment-popupjs@0.0.23/dist/umd/index.js"></script>

<!-- Staging/Test -->

<script src="https://unpkg.com/tap-payment-popupjs@0.0.20/dist/umd/index.js"></script>

You can now use the TAPPaymentPop.setup() method to create an instance of the payment gateway, passing in the required configuration parameters.

API

The TAPPaymentPop API consists of the following methods:

  • initialize(): Initializes the payment gateway with the specified configuration parameters.
  • setup(): Configures the payment gateway with the specified configuration parameters and returns an instance of the payment gateway.
  • openIframe(): Displays the payment gateway iframe.

Configuration Parameters

The TAPPaymentPop.setup() method requires a configuration object with the following parameters:

ParamsRequiredDescription
apiKeyyesYour TAP API key.
transIDyesA unique transaction ID.
amountyesThe amount of the transaction.
emailyesThe email address of the customer.
onClosenoA function to call when the payment gateway is closed.
callbacknoA function to call when the payment has been successfully completed.
customPayloadnoAn object containing additional custom data.
- billerIDnoThe biller ID (Special Usecase and to be in customPayload).
- productIDnoThe product ID (Special Usecae and to be in customPayload).
- ...noOther custom data you want to send with the transaction.

Example Usage:

Here is an example of how to use the TAPPaymentPop object to process payments:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>TAP Payment Gateway Example</title>
  </head>
  <body>
    <form id="pay-form">
      <div class="form-group">
        <label for="amount">Amount</label>
        <input
          type="number"
          id="amount"
          name="amount"
          class="form-control"
          required
        />
      </div>
      <div class="form-group">
        <label for="email">Email</label>
        <input
          type="email"
          id="email"
          name="email"
          class="form-control"
          required
        />
      </div>
        <div class="form-group">
        <label for="email">Phone</label>
        <input
          type="text"
          id="phone"
          name="phone"
          class="form-control"
          required
        />
      </div>
      <div class="form-group">
        <label for="email">Biller</label>
        <input
          type="text"
          id="billerID"
          name="billerID"
          class="form-control"
          required
        />
      </div>
       <div class="form-group">
        <label for="email">Product</label>
        <input
          type="text"
          id="productID"
          name="productID"
          class="form-control"
          required
        />
      </div>
      <button
        id="pay-btn"
        type="button"
        onclick="validateAndPay()"
        class="btn btn-primary"
      >
        Pay
      </button>
    </form>
    <div id="alert-holder"></div>
    <script src="https://unpkg.com/tap-payment-popupjs@0.0.20/dist/umd/index.js"></script>
    <script>
      const api_key = "TkdLb2VUMk46ZXRoWEdJSEF0Z24xOnB1WVUzd3dvS1c4bw==";

      function validateAndPay() {
        const email = document.getElementById("email").value;
        const amountinkobo = document.getElementById("amount").value;
        const phone = document.getElementById("phone").value;
        const fullname = "John Doe";

        // special usecase
        const billerID = document.getElementById("billerID").value;
        const productID = document.getElementById("productID").value;
        payWithTAP(email, amountinkobo, fullname, phone, billerID, productID);
      }

      function payWithTAP(email, amountinkobo, fullname, phone, billerID, productID) {
        const handler = TAPPaymentPop.setup({
          apiKey: api_key,
          amount: amountinkobo,
          transID: `KLMNOYZabcdefghijkl${Math.random().toString(36).slice(2)}qrstuvwxyz`,
          email: email,
          billerID: billerID,
          productID:productID
          customPayload: {
            fullname,
            phone,
            // special usecase
            billerID,
            productID,
          },
          callback: function (response) {
            console.log(response);
            const msg =
              'Success. The transaction id is <b>"' +
              response.transID +
              '"</b>';
            document.getElementById("alert-holder").innerHTML =
              '<div class="alert alert-success">' + msg + "</div>";
            document.getElementById("pay-form").reset();
          },
          onClose: function () {
            const msg = "Closed. Please click the 'Pay' button to try again";
            document.getElementById("alert-holder").innerHTML =
              '<div class="alert alert-info">' + msg + "</div>";
          },
        });
        handler.openIframe();
      }
    </script>
  </body>
</html>

Deployment

Inline JS is deployed to:



Live Checkout

Checkout Interface is deployed to:


0.0.23

2 months ago

0.0.20

4 months ago

0.0.21

4 months ago

0.0.19

4 months ago

0.0.18

6 months ago

0.0.10

12 months ago

0.0.11

11 months ago

0.0.12

11 months ago

0.0.13

11 months ago

0.0.14

9 months ago

0.0.9

12 months ago

0.0.16

9 months ago

0.0.8

12 months ago

0.0.17

9 months ago

0.0.7

12 months ago

0.0.6

12 months ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago