ngx-payunit
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

NgxPayunit

This is the official angular library for Payunit.

Installation

In your terminal, run

npm install ngx-payunit

Setup

Import NgxPayunitModule in your app.mopdule.ts and add in in the imports array

import { NgxPayunitModule } from 'ngx-payunit';

@NgModule({
  declarations: [AppComponent],
  imports: [
    NgxPayunitModule
  ],

Import NgxPayunitComponent

This component (NgxPayunitComponent) should be imported in the component where you perform payments. e.g -- payment.component.ts

 import { NgxPayunitComponent } from 'ngx-payunit';

Initialize and set required parameters

export class YourComponent implements OnInit {

  private payunit: NgxPayunitComponent;
  constructor() {
    this.payunit = new NgxPayunitComponent();
  }

  ngOnInit(): void {

    let config = {
      apiUsername: 'your_api_username_Ch8pif04d',
      apiPassword: 'your_api_password',
      x_api_key: 'your_api_key',
      mode: 'test', // should be 'test' for sandbox or 'live' when ready to go live
    };

    let data = {
      return_url: 'https://your_return_url.com',
      notify_url: 'https://your_notify_endpoint.com',
      description: 'Online payment with payunit angular sdk',
      purchaseRef: '7dg87sfd8adasf8798',
      total_amount: '5000',
      currency: 'USD',
    };

    this.payunit.config(config);
    this.payunit.payload(data);
  }

  makePayment() {
    this.payunit.pay();
  }
}

In your component.html add the snippet below

   <ngx-payunit></ngx-payunit>

   <button (click)="makePayment()">Purchase</button>

After successfully integrating and testing in sandbox, to go live, you simply need to change to live credentials and the mode to live mode.

Readme

Keywords

none

Package Sidebar

Install

npm i ngx-payunit

Weekly Downloads

0

Version

0.0.3

License

none

Unpacked Size

134 kB

Total Files

21

Last publish

Collaborators

  • sinclairekambang