1.0.3 • Published 9 months ago

pesaqr v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

A lightweight, framework-agnostic library for generating M-PESA Payment QR codes. Built using Web Components, PesaQR works seamlessly with any modern JavaScript framework or vanilla HTML.

Features

  • 🎯 Generate Payment QR codes for Till Numbers
  • 💳 Generate Payment QR codes for Paybill Numbers
  • 📱 Generate Payment QR codes for Phone Numbers (Send Money)
  • 🔌 Framework agnostic - works with React, Vue, Angular, or vanilla JavaScript
  • 📱 Mobile-responsive
  • 🔒 Offline support

Installation

npm install pesaqr

Usage

Basic HTML

<!-- Import the library -->
<script
  type="module"
  src="node_modules/pesaqr/dist/pesaqr.mjs"
></script>

<!-- Till Number Payment -->
<pesa-qr type="till" tillNumber="123456" amount="100" width="300"></pesa-qr>

<!-- Paybill Payment -->
<pesa-qr
  type="paybill"
  paybillNumber="888880"
  accountNumber="ACC123"
  amount="100"
  width="300"
></pesa-qr>

<!-- Phone Payment (Send Money) -->
<pesa-qr
  type="phone"
  phoneNumber="0712345678"
  amount="100"
  width="300"
></pesa-qr>

React

import "pesaqr";

function App() {
  return <pesa-qr type="till" tillNumber="123456" amount="100" width={300} />;
}

Vue

<template>
  <pesa-qr type="till" :tillNumber="'123456'" :amount="'100'" :width="300" />
</template>

<script>
import "pesaqr";

export default {
  name: "App",
};
</script>

Angular

// app.module.ts
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import 'pesaqr';

@NgModule({
  // ...
  schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule { }

// component template
<pesa-qr
  type="till"
  tillNumber="123456"
  amount="100"
  [width]="300"
></pesa-qr>

API Reference

Properties

PropertyTypeDescriptionRequired
typestringPayment type: "till", "paybill", or "phone"Yes
tillNumberstringTill number for till paymentsYes (for type="till")
paybillNumberstringPaybill number for paybill paymentsYes (for type="paybill")
accountNumberstringAccount number for paybill paymentsYes (for type="paybill")
phoneNumberstringPhone number for send money paymentsYes (for type="phone")
amountstringPayment amountYes
widthnumberQR code width in pixelsNo (default: 600)

Browser Support

  • Chrome/Edge (latest)
  • Firefox (latest)
  • Safari (latest)
  • Opera (latest)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

Author

David Amunga

portfolio linkedin twitter

Feedback

If you have any feedback or questions, please reach out to me on Twitter.

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago