1.0.0 • Published 2 years ago

advancly-widget-react v1.0.0

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

Advancly Widget React

This package enables you to give loans to your borrowers through Advancly widget. Install, and have fun with it.

Installation

To add Advancly Widget to your React project, run;

npm install advancly-widget-react

or

yarn add advancly-widget-react

and that's it, you're all good to go!

Screenshots of the widget

Usage

import { Fragment, useState } from "react";
import { AdvanclyWidget, advanclyProps } from "advancly-widget-react";

export default function App() {
  const [showModal, setShowModal] = useState(false);
  const onSuccess = (response: advanclyProps.IResponse) => {
    setShowModal(false);
    console.log("Success", JSON.stringify(response));
  };
  const onCancel = (response: advanclyProps.IResponse) => {
    setShowModal(false);
    console.log("Cancel", JSON.stringify(response));
  };

  return (
    <Fragment>
      <div
        style={{
          marginTop: 100,
          display: "flex",
          alignItems: "center",
          justifyContent: "center",
        }}
      >
        <button
          onClick={() => {
            setShowModal(true);
          }}
          style={{
            backgroundColor: "#377dff",
            padding: "10px 20px",
            borderRadius: "5px",
            borderColor: "#377dff",
            borderWidth: "1px",
          }}
        >
          Show Widget
        </button>
      </div>

      <AdvanclyWidget
        aggregator_id={29}
        bank_account_number="1122334455"
        bank_code="000"
        borrower_phone="08100000000"
        bvn_number="22222222222"
        aggregator_loan_ref={Date.now().toString()}
        cac_number="2222222"
        city="Mubuntu"
        company_name="HAIRTOPIA EX PARTE"
        customer_type="1"
        email="hellworld@gmail.com"
        first_name="John"
        gender="male"
        last_name="Doe"
        photo_url=""
        public_key="AAAAAAAAAAAA"
        residence_address="100 Lagos Road"
        state="Lagos"
        product_id={00}
        product_code="AAAA"
        tenure={00}
        customStyles={{
          buttonBackgroundColor: "#377dff",
          buttonTextColor: "#fff",
          acceptButtonBackgroundColor: "#377dff",
          acceptButtonTextColor: "#fff",
          declineButtonBackgroundColor: "#377dff",
          declineButtonTextColor: "#fff",
          dropdownTextColor: "#000",
          dropdownBackgroundColor: "#fff",
        }}
        onSuccess={onSuccess}
        onCancel={onCancel}
        showWidget={showModal}
        autoStart={false}
        environment={advanclyProps.ENVIRONMENT.TEST}
      />
    </Fragment>
  );
}

Props

NameDescriptionExtra Information
public_keyPublic key (sign up on aggregator.advancly.com to get yours)default: nill
aggregator_idThe ID of you the aggregator. You can get this on the settings page of your Advancly platform.default: nill
emailBorrower's email addressdefault: nill
first_nameBorrower's first namedefault: nill
last_nameBorrower's last namedefault: nill
genderBorrower's gender. male or femaledefault: nill
product_idThe ID of the loan product on Advancly platform. You can get this on the Loan Products page of your Advancly platformdefault: nill
product_codeThe code of the loan product on Advancly platform. You can get this on the Loan Products page of your Advancly platformdefault: nill
tenureBorrower's loan tenure (in days)default: nill
bank_account_numberBorrower's bank account numberdefault: nill
bank_codeBorrower's bank code on Advancly.default: nill
borrower_phoneBorrower's phone numberdefault: nill
bvn_numberBorrower's BVNdefault: nill
aggregator_loan_ref (not required)Loan reference number on aggregator platformdefault: Date.now().toString()
cac_number (not required)The borrower's CAC number. For corporate borrower onlydefault: nill
residence_addressThe borrower's addressdefault: nill
cityThe borrower's citydefault: nill
stateThe borrower's statedefault: nill
autoStartAuto start payment once page is openeddefault: false
company_name (not required)The name of the borrower's company. This is for corporate borrowers only.default: nill
customer_typeThis can be either 1 or 2. 1 is for individual borrowers. 2 is for corporate borrowersdefault: nill
photo_urlThe url of the borrower's image.default: nill
onCancelcallback function when borrower cancels the widgetdefault: nill
onSuccesscallback function when borrower's transaction is successfuldefault: nill
showWidgetA boolean that controls when then widget is showndefault: false
environmentAn enum that tells the environment the widget should be shown in. This can be either "test", "staging", "production".default: "test"

Contributions

Want to help make this package even more awesome? Read how to contribute and feel free to send in your PR!

Licensing

This project is licensed under MIT license.

Don't forget to star, like and share :)

Contributors ✨

Thanks goes to Gbenga Olufeyimi (@GbengaCodes) for creating this package (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!