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

hkqr-fps

v1.1.1

Published

Typescript implementation of Hong Kong Common QR Code / FPS QR Code

Downloads

80

Readme

HKQR-FPS

Typescript library for generating a QR Code following the standard by HKICL.

Intro

Fast Payment System (快速支付系統, also known as FPS 轉數快) was introduce since 2018. It actually follows a standard introduced by Hong Kong Interbank Clearing Limited (香港銀行同業結算有限公司). HKICL tried to create a common QR code that can be communicate between different payment service providers.

This repository contains two versions of code (HKQR and FPS) that follows the standard. One supports all the features under the standard while the other only support major features that is used in FPS.

It has been compiled to CommonJS and ES module. A webpacked version is also available. Please find it in dist/.

Usage

Directly import the .ts file.

import { HKQR } from "./src";           // or
import HKQR from "./src/HKQR";

let qrCode = new HKQR();

The typescript files have been compiled to CommonJS and ES Module. Files can be found in dist/.

To use in html without import module, javascript files have been compiled using Webpack. Include the script directly to html.

// index.html
<script src="HKQR.js></script>

// index.js
let qrCode = new HKQR();

Core Methods

ATTENTION: This repository DO NOT generate or decode QR Code. It only handles data before generating QR Code or after decoding QR Code.

Extract and Parse

  • HKQR.extract(x?: string): Event / FPS.extract(x: string): Event

Extracts the data from the QR Code if provided a string. Returns its data otherwise.

  • HKQR.parse(x: string): Event / FPS.parse(x: string): Event

Runs extract() and updates its data if extracts success.

Generate Output

  • HKQR.generate(): Event / FPS.generate(): Event

Generate final output for create QR Code.

Merchant/Receipant Identifier

  • HKQR.setMerchantAccountFPSId(x: number | string): Event / FPS.setFPSId(x: number | string): Event

Set 7-digit / 9-digit FPS ID as identifier.

  • HKQR.setMerchantAccountMobile(x: number | string): Event / FPS.setMobile(x: number | string): Event

Set mobile number as identifier. Format: +852-12345678

  • HKQR.setMerchantAccountEmail(x: string): Event / FPS.setEmail(x: string): Event

Set email as identifier.

Transaction Amount

  • HKQR.setTransactionAmount(x: number | string, fraction: number | boolean = false): Event / FPS.setAmount(x: number): Event

For HKQR.setTransactionAmount, you can convert a number to string in fixed-point notation (i.e. x.toFixed(fraction))

Billing Information

  • HKQR.setBillNumber(x: string): Event / FPS.setBillNumber(x: string): Event

Set the bill number/identifier provided by the merchant.

  • HKQR.setReferenceLabel(x: string): Event / FPS.setReference(x: string): Event

Set reference detail of the billing.

Event

Most of the functions return an Event class object. If there is no error, you can access event.data to get your data.

If there is any error, it will throw the error message causing the script to end. However, you can run HKQR.Silent() / FPS.Silent() to stop this behavior.

To handle error with silent enabled, you can use event.isError() to check if error exists. Get the error message with event.message.

Documentation

For HKQR, check here.

For FPS, check here.