0.0.3 • Published 1 year ago

thepeer-angular v0.0.3

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

thepeer-angular

Angular library for integrating Thepeer. Thepeer is a fast and secure way to send money accross businesses

INSTALLATION

To install, simply run the command:

npm install thepeer-angular

USAGE

Import the module

import { ThepeerModule } from 'thepeer';
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    ThepeerModule.forRoot('--YOUR PUBLIC KEY HERE--')
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Use in your project

There are two ways to implement this library in your project:

  • You can use functions that can be called from a template within your project as shown below:
import { ThepeerService } from 'thepeer'

constructor(private thePeerService: ThepeerService){}


  send(){
    this.thePeerService.initiateSend(config);
  }

  directDebit(){
    this.thePeerService.initiateDirectDebit(config);
  }

  checkout(){
    this.thePeerService.initiateCheckout(config);
  }
<button (click)="send()">Send</button>
<button (click)="directDebit()">Direct Debit</button>
<button (click)="checkout()">Checkout</button>
  • You can use a couple of pre-built components:
<thepeer-send 
    [config]="config"
>Send</thepeer-send>

<thepeer-direct-debit 
    [config]="config"
>Direct Debit</thepeer-direct-debit>

<thepeer-checkout 
    [config]="config"
>Checkout</thepeer-checkout>

The Config Object

The config object allows you to set your configuration options. A sample config object is shown below:

import { IEventResponse } from 'thepeer'

 config = {
    publicKey: "--PUBLIC KEY HERE--",
    amount: 10000,
    email: "toyosi@example.com",
    currency: "NGN",
    meta: {
        city: "Cupertino",
        state: "California"
    },
    onSuccess: (data: IEventResponse) => {
      console.log('success: ', data)
    },
    onError: (data: IEventResponse) => {
      console.log('error: ', data)
    },
    onClose: (data: IEventResponse) => {
      console.log('close: ', data)
    }
}

NOTE: The PUBLIC_KEY here is optional. If it is provided, it overrides the one in the module.

OptionDescriptionRequiredType
publicKeyYour public key can be found on your dashboard. It can either be provided in the module or as part of the config objecttruestring
amountThis is the amount to be sent and must be in kobo e.g N100 will be 10000trueinteger
userReferenceThe user reference uniquely identifies a user. It is returned when a user is indexed by using the Thepeer API. It is required when initiating send or direct debit functionalitiestruestring
metaThis contains optional values you will like to have with your transaction response.falseobject
emailYour customer's email. It is required for checkouttruestring
onSuccessIt is called when a transaction is successful.truefunction
onErrorIt is called when an error occurs.truefunction
onCloseIt is called when a user clicks the close buttontruefunction

THEPEER API REFERENCES

Thepeer API docs Thepeer Dashboard

SUPPORT

Please reach out to me at toyosioyelayo@gmail.com if you have any issues

CONTRIBUTING

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

License

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

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago