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

uni-vqr

v1.0.2

Published

A utility package for generating and handling VietQR codes.

Downloads

14

Readme

uni-vqr

A utility package for generating and handling VietQR codes.

Installation

npm install uni-vqr

Usage

const { generateVietQR } = require('uni-vqr');

// Example: Generate a VietQR code
const qrCode = generateVietQR({
  bankId: '970418',
  accountNumber: '123456789',
  accountName: 'John Doe',
  amount: 1000.5,
  message: 'Payment for invoice #123'
});

console.log(qrCode);

API Documentation

generateVietQR(options)

Generates a VietQR code string based on the provided parameters.

Parameters

  • options (Object): The options for generating the QR code.
    • bankId (string, required): The bank ID (NAPAS standard).
    • accountNumber (string, required): The recipient's account number.
    • accountName (string, optional): The recipient's account name.
    • amount (number, optional): The transfer amount.
    • message (string, optional): The transfer message.

Returns

  • string: The generated VietQR code string.

Example

const qrCode = generateVietQR({
  bankId: '970418',
  accountNumber: '123456789',
  accountName: 'John Doe',
  amount: 1000.5,
  message: 'Payment for invoice #123'
});

console.log(qrCode);
// Output: A string representing the VietQR code

Error Handling

Throws an error if required fields (bankId or accountNumber) are missing.

try {
  generateVietQR({ accountNumber: '123456789' });
} catch (error) {
  console.error(error.message); // Output: "bankId and accountNumber are required fields."
}

decodeVietQR(qrCode)

Decodes a VietQR code string and extracts its components.

Parameters

  • qrCode (string, required): The VietQR code string to decode.

Returns

  • Object: An object containing the decoded components:
    • bankId (string): The bank ID.
    • accountNumber (string): The recipient's account number.
    • accountName (string, optional): The recipient's account name.
    • amount (number, optional): The transfer amount.
    • message (string, optional): The transfer message.

Example

const { decodeVietQR } = require('uni-vqr');

const qrCode = '000201010211260600A0000007279704180112312345678902541000.5062Payment for invoice #1236304';
const result = decodeVietQR(qrCode);

console.log(result);
// Output:
// {
//   bankId: '970418',
//   accountNumber: '123456789',
//   amount: 1000.5,
//   message: 'Payment for invoice #123'
// }

Error Handling

Throws an error if the QR code string is invalid.

try {
  decodeVietQR('');
} catch (error) {
  console.error(error.message); // Output: "Invalid QR code string."
}

generateMoMoQR(options)

Generates a MoMo QR code string based on the provided parameters.

Parameters

  • options (Object): The options for generating the QR code.
    • partnerCode (string, required): The MoMo partner code.
    • partnerRefId (string, required): The reference ID for the transaction.
    • amount (number, required): The transaction amount.
    • description (string, optional): The transaction description.

Returns

  • string: The generated MoMo QR code string.

Example

const qrCode = generateMoMoQR({
  partnerCode: 'MOMO',
  partnerRefId: '123456789',
  amount: 50000,
  description: 'Payment for order #123'
});

console.log(qrCode);

decodeMoMoQR(qrCode)

Decodes a MoMo QR code string and extracts its components.

Parameters

  • qrCode (string, required): The MoMo QR code string to decode.

Returns

  • Object: An object containing the decoded components:
    • partnerCode (string): The MoMo partner code.
    • partnerRefId (string): The reference ID for the transaction.
    • amount (number): The transaction amount.
    • description (string, optional): The transaction description.

Example

const result = decodeMoMoQR('0002010102113804MOMO3909123456789545000062Payment for order #1236304');

console.log(result);
// Output:
// {
//   partnerCode: 'MOMO',
//   partnerRefId: '123456789',
//   amount: 50000,
//   description: 'Payment for order #123'
// }

generateZaloPayQR(options)

Generates a ZaloPay QR code string based on the provided parameters.

Parameters

  • options (Object): The options for generating the QR code.
    • appId (string, required): The ZaloPay app ID.
    • zpTransId (string, required): The transaction ID for ZaloPay.
    • amount (number, required): The transaction amount.
    • description (string, optional): The transaction description.

Returns

  • string: The generated ZaloPay QR code string.

Example

const qrCode = generateZaloPayQR({
  appId: 'ZALO',
  zpTransId: '123456789',
  amount: 100000,
  description: 'Payment for order #123'
});

console.log(qrCode);

decodeZaloPayQR(qrCode)

Decodes a ZaloPay QR code string and extracts its components.

Parameters

  • qrCode (string, required): The ZaloPay QR code string to decode.

Returns

  • Object: An object containing the decoded components:
    • appId (string): The ZaloPay app ID.
    • zpTransId (string): The transaction ID for ZaloPay.
    • amount (number): The transaction amount.
    • description (string, optional): The transaction description.

Example

const result = decodeZaloPayQR('0002010102113804ZALO39091234567895410000062Payment for order #1236304');

console.log(result);
// Output:
// {
//   appId: 'ZALO',
//   zpTransId: '123456789',
//   amount: 100000,
//   description: 'Payment for order #123'
// }

Features

✅ Generate QR codes based on VietQR format
✅ Parse existing VietQR codes to extract info like bank, account number, amount, message, etc.
✅ Bank-agnostic — works with many Vietnamese banks
✅ Follows the EMVCo standard (the global QR payment format used in VietQR)

Scripts

  • test: Runs the test suite using Mocha.
  • build: Placeholder for build steps (not required for this package).
  • publish: Publishes the package to npm.

License

MIT