--- name: vietqr-emv-offline description: "Generate, decode, verify, and render offline EMVCo / Napas 247 VietQR payment payloads and SVG QR codes for 57 Vietnamese banks using zero-dependency pure Python." category: development risk: safe source: https://github.com/vutantai95/vietqr-emv-python/blob/42bf9aa781af43c9db24f35e654fbc5de9ee06f7/SKILL.md source_repo: vutantai95/vietqr-emv-python source_type: community date_added: "2026-12-05" author: vutantai95 license: MIT license_source: https://github.com/vutantai95/vietqr-emv-python/blob/42bf9aa781af43c9db24f35e654fbc5de9ee06f7/LICENSE tags: [vietqr, emvco, napas, vietnam, qr-code, svg, python, payments, offline] --- # VietQR EMVCo Offline Adapted from [vutantai95/vietqr-emv-python](https://github.com/vutantai95/vietqr-emv-python/tree/42bf9aa781af43c9db24f35e654fbc5de9ee06f7) at commit `42bf9aa781af43c9db24f35e654fbc5de9ee06f7`. The upstream MIT notice is retained in `LICENSE`. ## Overview Builds, decodes, validates, and renders standard **EMVCo / Napas 247 VietQR** bank-transfer QR payloads completely offline using only the Python 3.9+ Standard Library. Supports 57 official SBV/Napas 6-digit Vietnamese bank BINs, automatic Vietnamese diacritic-to-ASCII memo sanitization, CRC-16/CCITT-FALSE (`0x1021`, init `0xFFFF`) verification, and a built-in pure-Python ISO/IEC 18004 SVG QR encoder (no `Pillow`, `qrcode`, or third-party QR image servers). ## When to Use - Use when generating static or dynamic VietQR payment payloads (auto-filled VND amount and transfer memo) for Vietnamese bank transfers. - Use when decoding or validating the CRC-16 checksum of an existing EMVCo VietQR string offline. - Use when rendering crisp vector SVG payment QR codes in privacy-sensitive environments without calling external QR image APIs. - Do not use for non-EMVCo payment rails (e.g., Stripe Checkout, PayPal, or non-Vietnam SEPA/UPI QR formats). ## Prerequisites - Python 3.9+ (zero external pip dependencies). - Local copy of `vietqr_emv.py` from `vutantai95/vietqr-emv-python`. - No network access, API keys, or banking credentials are required. ## How It Works ### 1. Establish the inputs Confirm the recipient bank code (e.g., `TCB`, `VCB`, `MB`, `BIDV`, `ACB`, or any 6-digit SBV BIN), account number, optional VND integer amount, and optional short transfer description (sanitized to <= 50 ASCII characters). Never request or store banking passwords, PINs, or OTPs. ### 2. Perform the task Run the offline CLI or import the Python module to build the EMVCo TLV string and optional SVG output: ```python from vietqr_emv import generate_vietqr_payload, generate_vietqr_svg, decode_vietqr payload = generate_vietqr_payload( bank="TCB", account_no="19036495308011", amount=49000, memo="Thanh toan don HD01", ) svg_markup = generate_vietqr_svg( bank="TCB", account_no="19036495308011", amount=49000, memo="Thanh toan don HD01", ) ``` CLI usage: ```bash python vietqr_emv.py --bank TCB --account 19036495308011 --amount 49000 --memo "Don HD01" --svg invoice_qr.svg --verify python vietqr_emv.py --decode "" python vietqr_emv.py --list-banks ``` ### 3. Verify the result Confirm `CRC_VALID=True` (via `verify_vietqr_crc(payload)` or `--verify`) and inspect the decoded TLV dictionary (`bank_bin`, `account_no`, `amount`, `memo`) before presenting the QR code to an end user. ## Examples ```text User request: Generate a dynamic VietQR payload and SVG for 150,000 VND to MB Bank account 0123456789 with memo "HD2026-09". Inputs: bank="MB" (BIN 970422), account_no="0123456789", amount=150000, memo="HD2026-09". Expected result (illustrative): An EMVCo TLV string starting with "000201010212..." containing AID "A000000727", BIN "970422", currency "704", amount "150000", country "VN", a valid 4-hex CRC16 suffix, and standalone "..." vector markup. ``` ## Limitations - Pure-Python SVG renderer supports ISO/IEC 18004 Byte Mode Versions 1-10 (up to 271 UTF-8 bytes, ECC Level L), which covers all standard VietQR payloads but not multi-kilobyte binary blobs. - Generates payment QR codes only; does not query bank balances, initiate transfers, or confirm whether a recipient paid. - Transfer memos are truncated to 50 ASCII characters per Napas 247 compatibility rules. ## Safety and side effects - **Risk level:** `safe` — offline deterministic computation and optional local SVG file write when `--svg` is specified. - **No network calls or secrets:** Never sends bank account numbers or amounts to third-party servers. Always double-check bank BIN, account number, and amount with the user before distributing payment QR codes. ## Sources and related skills - Upstream repository: [vutantai95/vietqr-emv-python](https://github.com/vutantai95/vietqr-emv-python) (MIT License, commit `42bf9aa781af43c9db24f35e654fbc5de9ee06f7`). - Related browser tools: [PayDesk Studio](https://vutantai95.github.io/paydesk-tools/).