1.0.3 • Published 3 years ago

ng-interswitch v1.0.3

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

NG INTERSWITCH

Issues Forks Stars

This is an angular library that makes interswitch payments integration very easy.

INSTALLATION

npm and angular2+ are required

To install the latest version of ng-interswitch, simply run the command:

npm install --save ng-interswitch

USAGE

1. Import the module

Import the module in your app.module.ts or any module in which the component is needed like so:

...
import { NgInterswitchModule } from 'ng-interswitch';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NgInterswitchModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

2. Implement in your project

The ng-interswitch component is used. The are to ways to configure the component.

1 . You can use the component properties directly like so:

<ng-interswitch
  [merchantCode]="'XXXXXXX'"
  [payItemID]="'XXXXXXXXXXXXXXXXXXXXX'"
  [amount]="'1000'"
  [customerEmail]="'toyosioyelayo@gmail.com'"
  [customerName]="'Toyosi Oyelayo'"
  (paymentCallback)="paymentCallback($event)"
  [class]="'btn btn-danger'"
>Make Payment</ng-interswitch>

2. If you are like me and you prefer to have the template as clean as possible, you can use the **paymentOptions property like so:

<ng-interswitch
  [paymentOptions]="paymentOptions"
  (paymentCallback)="paymentCallback($event)"
  [class]="'btn btn-danger'"
>Make Payment</ng-interswitch>

You can hence define paymentOptions in your ts file like so:

  paymentOptions = {
    merchantCode: 'XXXXXXXXX',
    payItemID: 'XXXXXXXXXXXXXXXXXXXXX',
    amount: 1000,
    customerEmail: 'toyosioyelayo@gmail.com',
    customerName: 'Toyosi Oyelayo'
  }

The event paymentCallback is raised after a transaction is completed. You can get the result of a transaction from the event handler assigned to it. A sample event handler will be like so:

  paymentCallback(data){
    console.log('data: ', data);
  }

AVAILABLE OPTIONS

Field NameData TypeRequiredDefault ValueDescription
merchantCodestringtrueundefinedThis can be found on your dashboard
PayItemIDstringtrueundefinedThis can be found on your dashboard.
payItemNamestringfalseundefinedThis is the name of the item the customer is paying for
amountnumbertrueundefinedThis is the total amount being paid (in kobo). Don't forget to add the transaction charges as appropriate
customerEmailstringtrueundefinedThe email of the customer
customerNamestringfalse''The name of the customer
customerIDstringfalse''ID of the customer
styleobjectfalse{}CSS stylings, eg {color: '#000000'}
classstringfalseundefinedText output of the component
currencynumberfalse566ISO 4217 code of the currency being used
siteRedirectURLstringfalsecurrent URLThe redirect URL after a transaction is completed
paymentModestringfalse"TEST"The payment mode. This can be 'LIVE' or 'TEST'
paymentOptionsobjectfalse{}This is an object that can take all other payment options
transactionReferencestringfalserandomly generated stringThis is a unique identifier for a transaction. It is handled by the package, but you can decide to create yours

TEST CARDS

TypeCard NumberExpiry DatePinCVVOTP
Verve506099058000021749903/501111111123456
Visa400000000000000203/501234111

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.

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago