0.0.3 • Published 3 years ago

ngx-mono v0.0.3

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

NGX-MONO

ngx-mono is an angular library to securely and quickly link bank accounts to Mono from within your app. It is built around Mono Connect.js. Mono Connect is a drop-in framework that handles connecting a financial institution to your app.

Visit Mono Docs for the detailed documentation.

REQUIREMENTS

Node 10 or higher

INSTALLATION

To install the latest version of ngx-mono, simply run the command

npm install --save ngx-mono

USAGE

1. Import the module

Import the library in your module:

import { NgxMonoModule } from 'ngx-mono'
2. Implement in your project
<ngx-mono
    [options]="options"
    (onSuccess)="onSuccess($event)"
>Connect</ngx-mono>
import { IMonoOptions } from 'ngx-mono'

  options:IMonoOptions = {
    key: <public_key>,
    data: {
      type: 'one-time-debit', // recurring-debit or one-time-debit
      amount: 150000, //amount in kobo
      description: "payment for light bill"
    }
  }

  onSuccess(data:any){
    console.log(data);
  }

OPTIONS

S/NOptionData TypeRequiredDescription
1keystringyesThe public key of your app. It can be gotten from the Mono dashboard.
2reauthTokenstringnoThis is only applicable to token re-authentication. Once this is present, a token re-authentication is initiated.
3scopestringnoThis should be set to ‘payments’ when integrating to Direct Debit
4data.typestringnoUsed when integrating to Direct Debit. Possible values are ‘one-time-debit’ and ‘recurring-debit’.
5data.amountintegernoAmount to be debited in kobo.
6data.descriptionstringnoDetails of what payment is being made for.

CALLBACKS

CallbackRequiredDescription
1onSuccessyesCalled after the successful onboarding of an account. It should take a single String argument containing the token that can be exchanged for an account id.
2onLoadnoCalled when the widget has been mounted unto the DOM.
3onClosenoCalled when a user has specifically exited the Mono Connect flow (i.e. the widget is not visible to the user). It does not take any arguments.
4onEventnoCalled when certain events in the Mono Connect flow have occurred, for example, when the user selected an institution. This enables your application to gain further insight into the Mono Connect onboarding flow.

EVENTS

Below are the possible events that can be raised by the onEvent callback: | Event Name | Description | |--------------------|-----------------------------------------------------------------------------------------------------| | OPENED | Triggered when the user opens the Connect Widget. | | EXIT | Triggered when the user closes the Connect Widget. | | INSTITUTION_SELECTED | Triggered when the user selects an institution. | | AUTH_METHOD_SWITCHED | Triggered when the user changes authentication method from internet to mobile banking, or vice versa. | | SUBMIT_CREDENTIALS | Triggered when the user presses Log in. | | ACCOUNT_LINKED | Triggered when the user successfully links their account. | | ACCOUNT_SELECTED | Triggered when the user selects a new account. | | ERROR | Triggered when the widget reports an error. |

SAMPLE SNIPPETS

1. Link Account

This is to link a user's account

<ngx-mono
    [options]="options"
    (onSuccess)="onSuccess($event)"
>Connect</ngx-mono>
import { IMonoOptions, IEventOptions } from 'ngx-mono';
 options:IMonoOptions = {
   key: '<public_key>'
 }
onSuccess(data:IEventOptions){
    console.log(data);
}

2. Reauthorization

<ngx-mono
    [options]="options"
    (onSuccess)="onSuccess($event)"
>Re-authorize</ngx-mono>
options:IMonoOptions = {
key: '<public_key>',
reauthToken: 'code_tPL0FVbsFuCqrBfMV4Vh'
}
onSuccess(data:IEventOptions){
    console.log(data);
}

3. Direct Debit

<ngx-mono
    [options]="options"
    (onSuccess)="onSuccess($event)"
>Direct debit</ngx-mono>
  options:IMonoOptions = {
    key: '<public_key>',
    scope: 'payments',
    data: {
       type: 'one-time-debit', // recurring-debit or one-time-debit
       amount: 150000, //amount in kobo
       description: "payment for electricity"
     }
  }

CONTRIBUTING

Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.

Star

I'd love you star this repo. Also follow me on twitter

License

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

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago