@kitmodule/kitnapas
v1.0.5
Published
Generate NAPAS EMV-QR payloads in vanilla JavaScript — lightweight, chainable, and dependency-free.
Maintainers
Readme
💳 KitNapas JS by Kitmodule
Generate NAPAS EMV-QR payloads in vanilla JavaScript — lightweight, chainable, and dependency-free.
✨ Features
- 🏦 Generate NAPAS 247 (QRIBFTTA) QR payloads.
- 🔗 Supports BIN, account number, amount, and add info.
- ⚡ Pure vanilla JavaScript, zero dependencies.
- 🧱 Fluent, chainable API.
- 🔒 Built-in CRC16 checksum.
🚀 Installation
Using npm
npm install @kitmodule/kitnapasUsing CDN
<script src="https://unpkg.com/@kitmodule/kitnapas/dist/kitnapas.min.js"></script>💡 Usage
Browser (CDN)
<script src="https://unpkg.com/@kitmodule/kitnapas/dist/kitnapas.min.js"></script>
<script>
const qr = new KitNapas("970436", "0651000837537")
.amount("50000")
.info("Nap tien NAPAS 247")
.payload();
console.log(qr);
</script>Node.js / ES Module
import { KitNapas } from "@kitmodule/kitnapas";
const qr = new KitNapas("970436", "0651000837537")
.amount("50000")
.info("Transfer to auth")
.payload();
console.log(qr);🧩 API Reference
kitmodule.napas(bin, accountNumber)
Create a new NAPAS QR generator instance.
| Param | Type | Description |
| --------------- | -------- | --------------------------- |
| bin | string | Bank BIN code (Acquirer ID) |
| accountNumber | string | Account or consumer ID |
Chainable methods
| Method | Description | Example |
| ---------------- | --------------------------------------------------------- | ------------------- |
| .amount(value) | Set transaction amount | .amount("50000") |
| .info(text) | Set additional info / purpose | .info("Nap tien") |
| .country(code) | Set country code (default: "VN") | .country("VN") |
| .dynamic() | Switch to dynamic QR (PointOfInitiationMethod = 12) | .dynamic() |
| .payload() | Generate the final EMV-QR string | .payload() |
Exports Overview
| Export | Type | Description |
| ------------------- | ---------- | --------------------------------------- |
| kitmodule.Napas | class | Class constructor |
| kitmodule.napas() | function | Factory shortcut returning new instance |
| KitNapas (global) | class | Global reference for browsers |
🧪 Example Output
const payload = new KitNapas("970436", "0651000837537")
.amount("50000")
.info("Donate auth")
.payload();
console.log(payload);Output (example):
00020101021138560010A000000727011600069704150112345678900203QRIBFTTA53037045406500005802VN621008086E6170206304A13B🧩 Integration with QRCode.js
Easily display the generated NAPAS payload as a scannable QR code using QRCode.js:
<!-- Include both libraries -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello, NAPAS QR!</title>
<link rel="stylesheet" href="styles.css">
<script src="https://unpkg.com/@kitmodule/kitnapas/dist/kitnapas.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/davidshimjs/qrcodejs/qrcode.min.js"></script>
</head>
<body>
<h1>NAPAS QR Code Demo</h1>
<div id="qrcode"></div>
<script>
// Generate NAPAS payload
const payload = new KitNapas("970436", "0651000837537")
.amount("100000")
.info("Donate auth KitNapas")
.payload();
console.log("Generated payload:", payload);
// Render QR code on the page
new QRCode(document.getElementById("qrcode"), {
text: payload,
width: 200,
height: 200,
colorDark: "#000000",
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.M
});
</script>
</body>
</html>This will display a valid NAPAS 247 EMV-QR image ready for banking apps to scan.
🤝 Contributing
Contributions are welcome! Open an issue or submit a pull request at github.com/kitmodule/kitnapas.
☕ Support the Author
🧾 License
Released under the MIT License © 2025 Huỳnh Nhân Quốc · Open Source @Kit Module
