1.0.8 • Published 2 years ago

react-interswitch v1.0.8

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

react-interswitch

Issues Forks Stars

Interswitch's official react package to easily integrate to Quickteller Business to recieve payments. To begin, create an account at https://business.quickteller.com if you haven't already.

Installation

To install, run:

npm install react-interswitch

Usage

Create your component like so:

import React from 'react'

import { InterswitchPay } from 'react-interswitch'

const App = () => {
  const paymentParameters = {
    merchantCode: 'XXXXXXX',
    payItemID: 'XXXXXXXXXXXX',
    customerEmail: 'johndoe@gmail.com',
    redirectURL: 'http://localhost:3000',
    text: 'Pay Now',
    mode: 'TEST',
    transactionReference: Date.now().toString(),
    amount: '10000',
    style: {
        width: '200px',
        height: '40px',
        border: 'none',
        color: '#fff',
        backgroundColor: '#ff0000'
    },
    callback: (response) => {
      console.log('response: ', response)
    }
  }
  return <InterswitchPay {...paymentParameters} />
}

export default App

Note:

Parameters

Below is a list of all the supported parameters.

ParametersData TypeRequiredDescription
merchantCodestringtrueThis can be found on your dashboard.
payItemIDstringtrueThis can be found on your dashboard.
customerEmailstringtrueThe email of the person making the payment.
amountstringtrueThe cost of the item being paid for in kobo.
transactionReferencestringtrueThis is a unique reference string required for every transaction. You can create a method to generate this.
textstringtrueThis represents the text on the payment button.
modestringtrueThis represents your integration mode. It can be 'TEST' or 'LIVE'.
callbackfunctiontrueThis function is called after every transaction.
redirectURLstringfalseThe url you want the user to be redirected to after a transaction.
currencystringfalseThe ISO code of the currency being used. If this field is not added, the currency naira is assumed.
customerNamestringfalseThe name of the person making the payment.
customerIDstringfalseThe ID of the person making the payment.
customerMobileNostringfalseThe mobile number of the person making the payment.
payItemNamestringfalseThe name of the item being paid for.
classNamestringfalseYou can use this to add a CSS class to the payment button.
styleobjectfalseYou can use this to add inline styles to the payment button.

After a transaction, a sample response from the callback function will be like so:

{
    amount: 10000,
    apprAmt: 10000,
    cardNum: "",
    desc: "Approved by Financial Institution",
    mac: "",
    payRef: "FBN|WEB|MX26070|13-04-2021|3512130|866194",
    resp: "00",
    retRef: "000106923853",
    txnref: "1618305656700",
    url: "http://localhost:3000",
}

NOTE: The key 'resp' gives the final status of the transaction.
There are quite a number of response codes that can be returned, the full list can be viewed here

- Handling the Response

For integrity purpose, you are advised to make a server side request to get the final status of a transaction before giving value. To do this, make a post request to the endpoint below:

Test mode:

https://qa.interswitchng.com/collections/api/v1/gettransaction.json?merchantcode={MERCHANT_CODE}&transactionreference={TRANSACTION_REFERENCE}&amount={AMOUNT_IN_KOBO}

Live mode:

https://webpay.interswitchng.com/collections/api/v1/gettransaction.json?merchantcode={MERCHANT_CODE}&transactionreference={TRANSACTION_REFERENCE}&amount={AMOUNT_IN_KOBO}

License

The MIT License (MIT). Please see License File for more information.

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago