Metadata-Version: 2.4
Name: vietqr-emvco
Version: 1.0.0
Summary: Lightweight VietQR Generator & Parser library for Python conforming to EMVCo standard
Author-email: VietQR Developer <developer@tenmiencuaban.com>
Keywords: vietqr,emvco,vietnam,napas,qrcode,banking,qr-code
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# 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:

```bash
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

```python
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

```python
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.
