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

asean-qr

v0.1.2

Published

Parse, validate and generate Southeast Asian payment QR codes (EMVCo): DuitNow, PayNow, PromptPay, QRIS and VietQR. Zero dependencies.

Readme

asean-qr

npm CI dependencies size license

Parse, validate and generate Southeast Asian payment QR codes with one API:

| | Scheme | Country | Generate | Decode | |---|---|---|---|---| | 🇲🇾 | DuitNow QR (PayNet) | Malaysia | ✅ | ✅ | | 🇸🇬 | PayNow (also inside SGQR) | Singapore | ✅ mobile, UEN | ✅ | | 🇹🇭 | PromptPay | Thailand | ✅ mobile, national ID, e-wallet, bill payment | ✅ | | 🇮🇩 | QRIS | Indonesia | ✅ static → dynamic, with fees | ✅ | | 🇻🇳 | VietQR (NAPAS) | Vietnam | ✅ account, card | ✅ |

All five are built on the same EMVCo merchant-presented QR standard, so the library is one small, well-tested EMVCo core plus a thin module per scheme. It also decodes the common fields of any other EMVCo QR.

  • Zero dependencies, 7.7 kB min+gzip for everything (3.9 kB if you only decode). Node, browsers, React Native, Deno, Bun.
  • Strict where it matters: checksum verified, lengths checked, amounts formatted per currency (no decimals for rupiah and dong), and inputs validated with clear errors before you print a QR nobody can pay.
  • Verified against real references: it reproduces PayNet's published DuitNow examples byte for byte and is cross-checked against the established single-country libraries (see How it's verified).
  • TypeScript-first: decoded results are a discriminated union, so qr.scheme === 'duitnow' gives you qr.acquirerId; ESM and CommonJS builds.
npm install asean-qr

Quick start

Decode anything a customer scans

import { decode } from 'asean-qr';

const qr = decode(scannedText); // throws QrError if the payload is damaged or the checksum is wrong

qr.scheme;          // 'duitnow' | 'paynow' | 'promptpay' | 'qris' | 'vietqr' | 'unknown'
qr.merchant.name;   // 'KEDAI KOPI'
qr.amount;          // '12.50' (exactly as encoded) or undefined when the payer types it
qr.currency;        // 'MYR'
qr.dynamic;         // true for a one-time QR

switch (qr.scheme) {
  case 'duitnow':   console.log(qr.acquirerId, qr.merchantId); break;
  case 'paynow':    console.log(qr.proxyType, qr.proxyValue, qr.expiry); break;
  case 'promptpay': console.log(qr.kind === 'transfer' ? qr.target : qr.billerId); break;
  case 'qris':      console.log(qr.nmid, qr.acquirers); break;
  case 'vietqr':    console.log(qr.bin, qr.account, qr.purpose); break;
}

Generate a QR

create() returns the payload text. Turn it into an image with any QR library, for example qrcode:

import QRCode from 'qrcode';
import { duitnow } from 'asean-qr';

const payload = duitnow.create({
  acquirerId: '501664',        // your acquiring bank's ID, from PayNet
  merchantId: '123456789',     // your merchant ID at that bank
  merchantName: 'KEDAI KOPI',
  city: 'CYBERJAYA',
  mcc: '5814',
  amount: '12.50',             // omit to let the payer enter the amount
});

await QRCode.toFile('pay.png', payload, { errorCorrectionLevel: 'M' });

Schemes

🇲🇾 DuitNow

import { duitnow } from 'asean-qr';

duitnow.create({
  acquirerId: '501664',
  merchantId: '123456789',
  merchantName: 'QRCSDNBHD',   // up to 25 characters
  city: 'BANGI',               // up to 15 characters
  mcc: '9999',                 // default '0000' (person to person)
  amount: '10.00',             // optional
});
// => '00020201021126410014A0000006150001...6304343F'  (PayNet's published retail example)

// Optional extras: postalCode, dynamic: true (one-time QR), and additionalData for tag 62
duitnow.create({ ...merchant, amount: 25, dynamic: true, additionalData: { billNumber: 'INV-0042' } });

const qr = duitnow.decode(payload);   // throws QrError('WRONG_SCHEME') for other schemes

DuitNow uses payload format version 02, as in PayNet's published examples; the library follows that.

🇸🇬 PayNow

import { paynow } from 'asean-qr';

paynow.create({ mobile: '9123 4567' });              // payer enters the amount
paynow.create({
  uen: '201234567A',
  amount: 88.8,                                      // '88.80'
  reference: 'INV-0042',                             // shown in the payer's app (tag 62.01)
  expiry: '20261231',                                // or a Date (its local date is used)
  editable: false,                                   // default: false with an amount, true without
  merchantName: 'Example Pte Ltd',
});

paynow.normalizeMobile('+65 9123 4567');             // '+6591234567'

decode() also finds PayNow inside a multi-scheme SGQR; every scheme on the code is listed in qr.accounts.

🇹🇭 PromptPay

import { promptpay } from 'asean-qr';

promptpay.create({ mobile: '081-234-5678', amount: 100 });    // mobile becomes 0066812345678
promptpay.create({ nationalId: '1-2345-67890-12-3' });       // or a tax ID, 13 digits
promptpay.create({ eWalletId: '123456789012345' });          // 15 digits

promptpay.billPayment({ billerId: '010555512345601', ref1: 'CUST0001', ref2: 'INV42', amount: 1500 });

🇮🇩 QRIS

A merchant's QRIS is issued by its acquirer, so instead of creating one from scratch you take the merchant's static QRIS and turn it into a one-time QR for the amount at checkout. Everything else stays as issued.

import { qris } from 'asean-qr';

const checkout = qris.withAmount(merchantStaticQris, 25000);                       // whole rupiah
const withFee  = qris.withAmount(merchantStaticQris, 25000, { fee: { fixed: 1000 } });
const withPct  = qris.withAmount(merchantStaticQris, 25000, { fee: { percent: 0.7 } });

const qr = qris.decode(checkout);
qr.nmid;              // national merchant ID, e.g. 'ID1020000000001'
qr.merchantCriteria;  // 'UMI' | 'UKE' | 'UME' | 'UBE' | 'URE'
qr.acquirers;         // [{ guid: 'ID.CO.BANK.WWW', merchantPan: '9360...', merchantId: '...' }]
qr.fee;               // { type: 'fixed', amount: '1000' }

🇻🇳 VietQR

import { asciiFold, vietqr } from 'asean-qr';

vietqr.create({
  bin: '970436',                                   // the bank's NAPAS BIN
  account: '0011001234567',
  amount: 150000,                                  // whole dong
  purpose: asciiFold('Thanh toán đơn hàng'),       // 'Thanh toan don hang': payment apps expect ASCII
});

vietqr.create({ bin: '970436', account: '9704361234567890', service: 'card' });

Tools

import { explain, isValid, validate, withAmount } from 'asean-qr';

isValid(text);              // boolean: structure and checksum
validate(text);             // { valid, error, warnings }: never throws

withAmount(staticQr, 25);   // any scheme: one-time copy with the amount, in the currency's format

console.log(explain(text)); // field-by-field breakdown, great in logs and bug reports
00  Payload format indicator                 02
01  Point of initiation method               11  (static: reusable)
26  Merchant account information
      00  Globally unique identifier         A0000006150001  (DuitNow, PayNet Malaysia)
      01  Acquirer ID                        501664
      02  Merchant or recipient ID           123456789
52  Merchant category code                   9999
53  Transaction currency                     458  (MYR)
54  Transaction amount                       10.00
58  Country code                             MY
59  Merchant name                            QRCSDNBHD
60  Merchant city                            BANGI
63  CRC                                      343F  (valid)

The same is available from the command line, no install needed:

npx asean-qr explain  "000202010211..."
npx asean-qr decode   "000202010211..."   # JSON
npx asean-qr validate "000202010211..."   # exit code 0 or 1

Lower-level building blocks are exported too: parsePayload, buildPayload, getTag, getSubTag, crc16, formatAmount, asciiFold, and the GUID and CURRENCY constants.

Errors

Everything the library rejects throws a QrError with a stable code, a readable message, and the tag it is about ('54', '26.02', ...). Parse errors also carry the character position.

| Code | Meaning | |---|---| | EMPTY | Nothing to parse | | MALFORMED | The TLV structure doesn't line up, or the payload doesn't start with tag 00 | | CRC_MISSING / CRC_MISMATCH | No checksum at the end, or it doesn't match (a damaged or tampered payload) | | INVALID_FIELD | A value is wrong: not a Singapore mobile number, a 7-digit national ID, decimals in rupiah... | | FIELD_TOO_LONG | Over the EMVCo limit, e.g. a merchant name longer than 25 characters | | MISSING_FIELD | A required input is empty | | WRONG_SCHEME | paynow.decode() was given a DuitNow QR, and so on |

Oddities that most payment apps tolerate (a missing country code, an overlong name in a QR someone else made) are reported in warnings instead of thrown. Pass { strict: true } to treat them as errors.

How it's verified

  • Official examples: PayNet's published DuitNow examples are reproduced byte for byte, including their checksums (343F, 3A23).
  • Cross-checked against established libraries (dev dependencies only), on every CI run:
  • Property-based tests (fast-check), about 10,000 generated cases per run: the parser only ever throws QrError on arbitrary input, every single-character change to a valid payload is detected, every 2-decimal amount formats exactly, and generated QRs round-trip through decode().
  • Independent fixtures: test payloads are encoded by a separate script, not by the library itself.

Good to know

  • A QR is not a payment. Decoding tells you what the payer will be asked to pay. Confirm the payment from your bank or payment provider (webhook or status API) before releasing goods.
  • Static vs dynamic: a static QR (dynamic: false) can be paid many times; a dynamic one is meant for a single payment. Banks may treat them differently, so use dynamic QRs for checkouts.
  • Test with real apps before going live. Schemes evolve, and some banks are stricter than the specifications.
  • This is an independent open-source project. It is not affiliated with or endorsed by PayNet, the Association of Banks in Singapore, Bank of Thailand, Bank Indonesia, NAPAS or EMVCo. Scheme names are trademarks of their owners.

Contributing

Issues and pull requests are welcome, especially real-world payloads that don't decode as expected (please replace account numbers first) and more schemes, such as Cambodia's KHQR or the Philippines' QR Ph.

npm install
npm test          # unit, interoperability and property tests
npm run lint
npm run build

License

MIT © Ahmad Amirizal Rahmat