vietqr-zero
v1.0.0
Published
Zero-dependency VietQR library with bank list (base64 logos) and QR code generation
Downloads
10
Maintainers
Readme
VietQR-Zero
Zero-dependency VietQR library for Node.js and browsers. Generate VietQR payment codes and access Vietnamese bank information with pre-processed base64 logos.
Features
✨ Zero Runtime Dependencies - No external packages required
🏦 Complete Bank List - All Vietnamese banks with logos (150px, WebP, base64)
💳 VietQR Generation - Create payment QR codes following VietQR standards
📦 Dual Module Support - ESM and CommonJS builds included
🔒 TypeScript Support - Full type definitions included
Installation
npm install vietqr-zeroUsage
Get Bank List
import { getBankList } from 'vietqr-zero';
const banks = getBankList();
banks.forEach(bank => {
console.log(`${bank.shortName}: ${bank.name}`);
// Logo is available as base64: bank.logoBase64
// Use directly in img tag: <img src="${bank.logoBase64}" alt="${bank.shortName}" />
});Generate VietQR Code
import { makeVietQRContent } from 'vietqr-zero';
const qrContent = makeVietQRContent({
bankId: '970415', // Bank BIN (use bank.bin field, e.g., '970415' for VietinBank)
accountId: '1234567890', // Account number
amount: 50000, // Optional: amount in VND
description: 'Payment' // Optional: transaction description
});
// Use qrContent with any QR code generator library
console.log(qrContent);Bank Data Structure
interface Bank {
id: number;
name: string; // Full bank name
code: string; // Bank code (e.g., "ICB", "VCB")
bin: string; // Bank identification number (use as bankId for VietQR)
shortName: string; // Short display name
logoBase64: string; // Base64-encoded WebP logo (150px height)
transferSupported: number; // 1 if transfer is supported
lookupSupported: number; // 1 if lookup is supported
swiftCode: string | null; // International SWIFT code
}CommonJS Usage
const { getBankList, makeVietQRContent } = require('vietqr-zero');
const banks = getBankList();
const qrCode = makeVietQRContent({
bankId: '970436', // Use bank.bin field (e.g., '970436' for Vietcombank)
accountId: '9876543210'
});Building from Source
This package includes a build-time script that fetches the latest bank data and processes logos:
npm install # Install dependencies
npm run build # Build the packageThe build process:
- Fetches bank data from VietQR API
- Downloads each bank's logo
- Resizes to max 150px height (maintains aspect ratio)
- Converts to WebP format
- Encodes to base64
- Compiles TypeScript to ESM and CommonJS
Zero Dependencies
This package has zero runtime dependencies. All bank logos are pre-processed during build time and included as base64 strings, eliminating the need for image processing libraries at runtime.
License
MIT
Contributing
Issues and pull requests are welcome at the main repository.
