Lightweight VietQR Generator & Parser library for Python conforming to EMVCo standard
Project description
VietQR EMVCo Generator & Parser for Python
A lightweight, zero-dependency Python library to generate and parse VietQR codes conforming to the EMVCo standard spec (used by Napas for Vietnam banking QR codes).
Installation
Install using pip:
pip install vietqr-emvco
Features
- No external dependencies: Only uses standard Python libraries.
- Generator: Generate standard EMVCo-compliant VietQR strings with dynamic amount, memo, and beneficiary details. Includes automatic bank BIN resolution for popular Vietnamese banks.
- Parser: Decompose a raw VietQR string into structured tags (Acquirer BIN, Account Number, Amount, Currency, Country, Merchant Name, Transaction Memo).
- CRC16 Checker: Verify whether a VietQR string has a valid checksum.
Quick Start
1. Generate VietQR
from vietqr_emvco import VietQRGenerator
# Initialize with Bank name (MBBank, Vietcombank, etc.) or 6-digit Acquirer BIN
vietqr = VietQRGenerator(bank="MBBank", account="12345678900")
# Generate standard EMVCo text
qr_text = vietqr.generate(
amount=100000,
memo="ITBLOG PAY 123",
merchant_name="NGUYEN VAN A"
)
print("Raw EMVCo string:", qr_text)
# Generate image URL using VietQR.io template
image_url = vietqr.generate_image_url(
amount=100000,
memo="ITBLOG PAY 123",
merchant_name="NGUYEN VAN A"
)
print("Image URL:", image_url)
2. Parse VietQR
from vietqr_emvco import VietQRParser
qr_text = "00020101021238540010A00000072701240006970422011012345678900208QRIBFTTA52040000530370454061000005802VN5912NGUYEN VAN A62180810ITBLOG PAY16304E85C"
# Verify CRC16 checksum
is_valid = VietQRParser.verify_checksum(qr_text)
print("Checksum valid:", is_valid)
# Parse to structured data
details = VietQRParser.parse(qr_text)
print("Bank BIN:", details["bank_bin"])
print("Account Number:", details["account_number"])
print("Amount:", details["amount"])
print("Memo:", details["memo"])
print("Merchant Name:", details["merchant_name"])
List of Supported Bank Aliases
You can pass the following aliases to VietQRGenerator(bank=...):
MBBank(BIN:970422)Vietcombank(BIN:970436)Techcombank(BIN:970407)BIDV(BIN:970418)Vietinbank(BIN:970415)VPBank(BIN:970432)TPBank(BIN:970423)ACB(BIN:970416)Sacombank(BIN:970403)HDBank(BIN:970437)- ... or any 6-digit BIN code directly.
License
MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vietqr_emvco-1.0.0.tar.gz.
File metadata
- Download URL: vietqr_emvco-1.0.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06c23fefa3bc09277f3c3a243abb70fb7f8b135ef32baa9856754768972b759e
|
|
| MD5 |
4076fdbf8b30b6b21e12f4e5118f97bc
|
|
| BLAKE2b-256 |
69c5bb4c699e6524171d726b7f5b68b3443c0fbe4480a3f1dbbaee56b190995f
|
File details
Details for the file vietqr_emvco-1.0.0-py3-none-any.whl.
File metadata
- Download URL: vietqr_emvco-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e082619ac1a00254e63f0dae84c30c9c5c25afc52ead086448b9588edc3ef527
|
|
| MD5 |
91cb1309bbf70fb1cd8d6542c47a48ac
|
|
| BLAKE2b-256 |
a3f8df46e4c652e317a264685b9951bc34dd595707291edbf7c12030370d9727
|