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 🙏

© 2024 – Pkg Stats / Ryan Hefner

bakong-khqr

v1.0.17

Published

KHQR javascript SDK

Downloads

1,000

Readme

KHQR (Khmer QRCode)

KHQR is the centralized QRCode for Cambodia, where every mobile banking app in Cambodia can scan and pay. KHQR ~ Scan.Pay.Done.

Changelog

  • decode caching

Installation

Run unit test

npm run test

NPM

npm install bakong-khqr

Raw Script

Link the script src to html

<script src="https://github.com/davidhuotkeo/bakong-khqr/releases/download/bakong-khqr-1.0.6/khqr-1.0.6.min.js"></script>

Usage

NPM

const {BakongKHQR, khqrData, IndividualInfo, MerchantInfo, SourceInfo} = require("bakong-khqr");

or

import {BakongKHQR, khqrData, IndividualInfo, MerchantInfo, SourceInfo} from "bakong-khqr";

Raw Script

In your script file/tag

var {BakongKHQR, khqrData, IndividualInfo, MerchantInfo, SourceInfo} = BakongKHQR;

How to use KHQR Javascript Library?

Generate KHQRCode

There are 2 way of generating KHQR: Individual and Merchant

Merchant KHQR

const {BakongKHQR, khqrData} = require("bakong-khqr");
const optionalData = {
    currency: khqrData.currency.khr,
    amount: 100000,
    billNumber: "#0001",
    mobileNumber: "85587575857",
    storeLabel: "Devit Huotkeo",
    terminalLabel: "Devit I",
};

const merchantInfo = new MerchantInfo(
    "devit@abaa",
    "devit",
    "Battambang",
    1243546472,
    "DEVBKKHPXXX",
    optionalData
);

const khqr = new BakongKHQR();
const response = khqr.generateIndividual(merchantInfo);

console.log(response);

Individual KHQR

const {BakongKHQR, khqrData} = require("bakong-khqr");
const optionalData = {
    currency: khqrData.currency.khr,
    amount: 100000,
    billNumber: "#0001",
    mobileNumber: "85587575857",
    storeLabel: "Devit Huotkeo",
    terminalLabel: "Devit I",
};

const individualInfo = new IndividualInfo(
    "devit@abaa",
    khqrData.currency.khr,
    "devit",
    "Battambang",
    optionalData
);

const khqr = new BakongKHQR();
const response = khqr.generateIndividual(individualInfo);

console.log(response);

Verify KHQR

const {BakongKHQR} = require("bakong-khqr");

const KHQRString =
    "00020101021230190015john_smith@devb5204599953038405405500.05802KH5910John Smith6010Phnom Penh62640111Invoice#0690314Coffee Khlaing0727Cooooooooooooooooooounter 299170013161406568381963040F76";
const isKHQR = BakongKHQR.verify(KHQRString).isValid;

console.log(isKHQR);

Decode

const {BakongKHQR, khqrData} = require("bakong-khqr");

const KHQRString =
    "00020101021230190015john_smith@devb5204599953038405405500.05802KH5910John Smith6010Phnom Penh62640111Invoice#0690314Coffee Khlaing0727Cooooooooooooooooooounter 299170013161406568381963040F76";
const decodeResult = BakongKHQR.decode(KHQRString);
console.log(decodeResult);

Deeplink

const {BakongKHQR, khqrData, SourceInfo} = require("bakong-khqr");

const khqr = new BakongKHQR();

// Source Info is optional but if you include it
// all fields appIconUrl, appName, appDeepLinkCallback must not be null
const sourceInfo = new SourceInfo(yourAppIconUrl, yourAppName, yourAppDeepLinkCallback);
const url = "generate deep link url provided by us";
const KHQRString =
    "00020101021230190015john_smith@devb5204599953038405405500.05802KH5910John Smith6010Phnom Penh62640111Invoice#0690314Coffee Khlaing0727Cooooooooooooooooooounter 299170013161406568381963040F76";

const deepLinkURL = khqr.generateDeepLink(url, KHQRString, sourceInfo);

deepLinkURL.then(url => console.log(url))

Check bakong account ID

const {BakongKHQR} = require("bakong-khqr");

BakongKHQR.checkBakongAccount(
    "open API URL",
    "dave@devb"
).then((data) => console.log(data));