npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

angular-klasha

v0.0.1

Published

Angular wrapper for integrating klasha transactions

Readme

angular-klasha

This is an angular module that abstracts the complexity of making klasha payments.

Demo

Demo

USAGE

1. Install the module

npm install --save angular-klasha

2. Import the module

In your app.module.ts or any module where the component or directive would be used like so:

import { NgModule } from '@angular/core';

import { AngularKlashaModule } from 'angular-klasha';
...

@NgModule({
  imports: [
    AngularKlashaModule.forRoot('merchantKey','businessId',false),
  ]
})

export class AppModule {}

3. Implement in your project

There are two available options

  • AngularKlashaComponent: Renders a button which when clicked loads klasha Inline in an iframe

    <angular-klasha
      [fullname]="'some-random-str'"
      [phone_number]="'some-random-str'"
      [paymentDescription]="'some-random-str'"
      [email]="'[email protected]'"
      [amount]="'1000000'"
      [merchantKey]="'some-random-str'"
      [businessId]="'some-random-str'"
      [tx_ref]="'some-random-str'"
      (paymentInit)="paymentInit()"
      (callBack)="paymentDone($event)"
    >
      Pay with Klasha
    </angular-klasha>
  • AngularKlashaDirective: A directive that loads klasha inline in an iframe when clicked

<button
  angular-klasha
  [fullname]="'some-random-str'"
  [phone_number]="'some-random-str'"
  [paymentDescription]="'some-random-str'"
  [email]="'[email protected]'"
  [amount]="'1000000'"
  [merchantKey]="'some-random-str'"
  [businessId]="'some-random-str'"
  [tx_ref]="'some-random-str'"
  (paymentInit)="paymentInit()"
  [class]="'btn btn-primary'"
  (callBack)="paymentDone($event)"
>
  Pay with Klasha
</button>

And then in your component.ts

import { Component, OnInit } from "@angular/core";

@Component({
  selector: "app-root",
  templateUrl: "./app.component.html",
  styleUrls: ["./app.component.css"],
})
export class AppComponent implements OnInit {
  tx_ref = '' + Math.floor((Math.random() * 1000000000) + 1);
  constructor() {}

  paymentInit() {
    console.log("Payment initialized");
  }

  paymentDone(info: any) {
    this.title = "Payment Done";
    console.log(this.title, info);
  }

  ngOnInit() {
     this.tx_ref ='' + Math.floor((Math.random() * 1000000000) + 1);
  }
}

Also you can use the klashaOptions object like so:

<button
  angular-klasha
  [klashaOptions]="options"
  (paymentInit)="paymentCancel()"
  (callBack)="paymentDone($event)"
>
  Pay with Klasha
</button>

And then in your component.ts

import { Component } from "@angular/core";
import { KlashaOptions } from "angular-klasha";

@Component({
  selector: "app-root",
  templateUrl: "./app.component.html",
  styleUrls: ["./app.component.css"],
})
export class AppComponent {
  options: KlashaOptions = {
    email: 'some-random-str',
    phone_number: 'some-random-str',
    merchantKey: 'some-random-str',
    amount: 1000,
    sourceCurrency: '',
    destinationCurrency: '',
    tx_ref: '' + Math.floor((Math.random() * 1000000000) + 1),
    businessId: '1',
    fullname: 'some-random-str',
    paymentDescription: '',
    kit: {
      currency: '',
      phone_number: 'some-random-str',
      email: 'some-random-str',
      fullname: 'some-random-str',
      tx_ref: '',
      paymentType: '',
    }
  ;
  constructor() {}

  paymentInit() {
    console.log("Payment initialized");
  }

  paymentDone(info: any) {
    this.title = "Payment Done";
    console.log(this.title, info);
  }

}

Also, you can pass in a merchantKey and businessId in the component and the directive, in such situation, this merchantKey and businessId is given a higher ptx_ref over the global forRoot merchantKey and businessId. For example, if you have this is your file

@NgModule({
  imports: [
    AngularKlashaModule.forRoot('merchantKey','businessId',false),
  ]
})

and this in your component

<button
  angular-klasha
  [fullname]="'some-random-str'"
  [phone_number]="'some-random-str'"
  [paymentDescription]="'some-random-str'"
  [email]="'[email protected]'"
  [amount]="'1000000'"
  [merchantKey]="'merchantKey2'"
  [businessId]="'businessId2'"
  [tx_ref]="'some-random-str'"
  (callBack)="paymentDone($event)"
>
  Pay with Klasha
</button>

Then merchantKey2 and businessId2 would be used instead

OPTIONS

The function accepts some parameters necessary for processing payment, and they include the following:

| Parameters | Description | | --------------- | --------------------------------------------------------------------------------------------------------------------------- | | merchantKey | The key generated by the merchant after creating a business in the merchant dashboard. It can be the public or private key. | | amount | The amount that is paid by the customer to the merchant. | | Container id | The id of an empty container div in your code. by default it is generated | | callbackUrl | The url your customers are being redirected to after processing payment. | | destinationCurrency | The country code e.g NGN (Nigeria). | | sourceCurrency | The currency set by the merchant in which the price of goods is displayed. | | phone_number | The customer’s phone number. | | email | The customer’s email address. | | fullname | The customer’s full name. | | tx_ref | The transaction reference number. It calls a javascript function makeid(8) where 8 is the length of the id. The length can be any number you desire and an example format is; klasha-8 to 12 digits-datetime (klasha-0123456789-01022021). | | Kit | A JSONArray containing the customer’s info as well as the transaction reference.|

Kit can further be broken down into:

| Parameters | Description | | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | currency | The currency in which payment is made. | | phone_number | The customer’s phone number. | | email | The customer’s email address. | | fullname | The customer’s full name. | | tx_ref | The transaction reference number. It calls a javascript function makeid(8) where 8 is the length of the id. The length can be any number you desire and an example format is; klasha-8 to 12 digits-datetime (klasha-0123456789-01022021). | | Call back | A javascript function that is called after the payment has been made. It can return a successful or failed message depending on the status of the transaction. |

For more information checkout klasha's documentation

Contributing

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

How can I thank you?

Why not star the github repo? I'd love the attention! Why not share the link for this repository on Twitter or anywhere? Spread the word!

Don't forget to follow me on twitter!

Thanks! Dansteve Adekanbi.

License

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