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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@pqthanh/pay-code-gen

v0.0.2

Published

A package to generate pay codes for fast money transfer (excluding QR code generation).

Downloads

46

Readme

@pahm/pay-code-gen

A package to generate pay codes for fast money transfers in the VietQR format. This package allows you to easily construct the content for payment QR codes using a builder pattern.

Features

  • Generate Pay Codes: Create pay codes based on VietQR standards.
  • Builder Pattern: Use a builder pattern to fluently construct pay codes.

Installation

To install the package, you can use npm, yarn or pnpm:

npm install @pahm/pay-code-gen
# or
yarn add @pahm/pay-code-gen
# or
pnpm i @pahm/pay-code-gen

Usage

This package provides a PayCodeGen class that implements the builder pattern. You can fluently build a pay code with the required fields and then generate the final pay code string.

Example

Static QR code with an account and content:

import PayCodeGen from "@pahm/pay-code-gen";

// Create a new pay code instance
const payCode = new PayCodeGen()
  .acquirer("970403") // set the acquirer id (bin)
  .cosumer("0011012345678") // set the cosumer account id
  .cosumerType("A") // set type account ("A" as Account)
  .currency(704) // set the currency (Vietnamese Dong)
  .country("VN") // default is VN (default)
  .content("any content"); // add content for transaction

// Get the final pay code string
console.log(payCode.toString());

Static QR code to card with content:

import PayCodeGen from "@pahm/pay-code-gen";

// Create a new pay code instance
const payCode = new PayCodeGen()
  .acquirer("970403") // set the acquirer id (bin)
  .cosumer("9704031101234567") // set the cosumer card id
  .cosumerType("C") // set type account ("C" as card)
  .currency(704) // set the currency (Vietnamese Dong)
  .country("VN") // default is VN (default)
  .content("any content"); // add content for transaction

// Get the final pay code string
console.log(payCode.toString());

Methods Summary

acquirer(id): Sets the acquirer ID (e.g., the merchant ID).

consumer(data): Sets the consumer data.

currency(currency): Sets the currency using the ISO 4217 code (default is Vietnamese Dong 704).

amount(value): Sets the payment amount.

country(countryCode): Sets the country code (default is "VN" for Vietnam).

category(catId): Sets the category ID (e.g., "001").

tip(): Sets a fixed tip, removing fee-related fields.

fixedFee(value): Sets a fixed fee, removing percentage fee and amount.

percentFee(value): Sets a percentage fee, removing the fixed fee and amount.

bankName(name): Sets the bank name.

city(name): Sets the city name.

portal(code): Sets the portal code (e.g., "100000").

additional(id, content): Adds additional content with the given ID (e.g., custom information).

id
  • BILL_NUMBER: Invoice/receipt number issued by Merchant or automatically entered by the Customer Application
  • MOBILE_NUMBER: The mobile phone number can be provided by the merchant or entered by the customer.
  • STORE_LABEL: A special value associated with a store. This value can be provided by the merchant or entered by the customer.
  • LOYALTY_NUMBER: Usually the loyalty card number. This number may be provided by the merchant or the customer may have to enter their Loyalty Card Number.
  • REFERENCE_LABEL:
  • CUSTOMER_LABEL: Can be customer code, customer phone number, invoice number.
  • TERMINAL_LABEL: A unique code associated with the store's terminal.
  • PURPOSE_OF_TRANSACTION: Value to determine the purpose of the transaction, eg: phone top-up, purchase of goods...
  • ADDITIONAL_CONSUMER_DATA_REQUEST: One or more of the following characters may appear, indicating the corresponding data that needs to be provided during transaction initiation:
    • "A" = Customer address
    • "M" = Customer phone number
    • "E" = Customer email address

content(content): Adds content to the pay code. This is a more general method for adding content.

Acknowledgements

This package follows the VietQR standards for generating payment QR codes, which are widely used for fast and secure mobile payments in Vietnam.