1.1.2 • Published 2 years ago

collect-africa-js v1.1.2

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

Collect Widget - JavaScript SDK

JS library for implementing the Collect widget - CollectWidgetJS is a safe and secure web drop-in module and this library provides a front-end web with ability to make payment for each bank that Collect supports.

Try the demo

Checkout the widget flow to view how the Collect Widget works. Click "See How it Works"

Before getting started

  • Retrieve your Client Public API Keys.
  • Create a sandbox customer, so you can get connecting immediately.

Installing

Using npm:

$ npm install collect-africa-js

Using yarn:

$ yarn add collect-africa-js

Using CDN:

<script src="https://cdn.collect.africa/collect-africa.js"></script>

Usage

For JS frameworks import it and use

import CollectCheckoutService from 'collect-africa-js';

For others, just use

const checkout = new CollectCheckoutService({
  email: 'peterparker@gmail.com',
  firstName: 'Peter',
  lastName: 'Parker',
  reference: 'XXXXX-XXXXX',
  amount: 1000000, // in Kobo
  currency: 'NGN', // NGN
  itemImage: '', // URL for item image
  paymentLinkCode: '', // Payment link code
  invoiceCode: '', // Invoice code
  planCode: '', // Plan code
  publicKey: 'pk_sandbox_XXXXXXXXXX', // Your public key
  onSuccess(e) {
    console.log('payment successful.', e);
  },
  onClose(e) {
    console.log('closed the widget.', e);
  },
});

checkout.setup();
checkout.open();

CollectWidget Options

NameTypeRequiredDefault ValueDescription
emailStringtrueEmail address.
firstNameStringtrueFirst name.
lastNameStringfalseLast name.
referenceStringtrueUnique transaction reference
amountNumbertrueAmount to charge.
currencyStringfalseNGNProcessing currency
itemImageString(URL)falseURL for item image
publicKeyStringtrueThe Collect public api key.
paymentLinkCodeStringfalseThe payment link code.
invoiceCodeStringfalseThe invoice code.
planCodeStringfalseThe plan code.
logoString(URL)falseCollect's Logo
callbackUrlString(URL)false
onSuccessFunctionfalseAction to perform after widget is successful
onCloseFunctionfalseAction to perform if widget is closed
onErrorFunctionfalseAction to perform on widget Error
beforeCloseFunctionfalseAction to perform before widget close

Other information

For enquires and questions, contact