0.0.3 • Published 3 years ago

ngx-payunit v0.0.3

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

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.

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago