KHQR / EMVCo merchant-presented QR payload generator for Bakong (Cambodia), with CRC16 verification.
Project description
konthaina-khqr
KHQR / EMVCo merchant-presented QR payload generator for Bakong / Cambodia (NBC KHQR spec v2.7-style TLV) with CRC-16/CCITT-FALSE verification.
This package generates the payload string (the EMV tag-length-value text) that you can encode into a QR image.
Install
pip install konthaina-khqr
Optional: generate QR images (PNG) using qrcode:
pip install "konthaina-khqr[qrcode]"
Quick start
from konthaina_khqr import KHQRGenerator, MerchantType, Currency
result = (
KHQRGenerator(MerchantType.INDIVIDUAL)
.set_bakong_account_id("john_smith@devb")
.set_merchant_name("John Smith")
.set_currency(Currency.USD)
.set_amount(100.50)
.set_merchant_city("Phnom Penh")
.generate()
)
print(result.qr) # KHQR payload string
print(result.md5) # md5 of payload
Verify / decode
from konthaina_khqr import verify, decode
ok = verify(result.qr)
data = decode(result.qr) # simple TLV decode
CLI
khqr --type individual --bakong john_smith@devb --name "John Smith" --amount 1.25 --currency USD
Generate a PNG (requires extras):
khqr --type individual --bakong john_smith@devb --name "John Smith" --amount 1.25 --currency USD --png out.png
Development
python -m venv .venv
. .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
pytest
ruff check .
mypy src
Build & publish
Build:
python -m build
twine check dist/*
Publish to TestPyPI:
twine upload -r testpypi dist/*
Publish to PyPI:
twine upload dist/*
For GitHub Actions + Trusted Publishing, see .github/workflows/publish.yml.
Project details
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 konthaina_khqr-0.1.6.tar.gz.
File metadata
- Download URL: konthaina_khqr-0.1.6.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccbdbc3102d554729892b952edc7a521bfedb7948031fb6ccfd72f4f7ed03834
|
|
| MD5 |
b18caa4af18c8ee0403b3bfaccc6c2f5
|
|
| BLAKE2b-256 |
3a2b8ca5fcdc738b593dd5fa951ee4dceea66a25b696fd0ba0fd3d1b41b815a8
|
Provenance
The following attestation bundles were made for konthaina_khqr-0.1.6.tar.gz:
Publisher:
publish.yml on Konthaina/khqr-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
konthaina_khqr-0.1.6.tar.gz -
Subject digest:
ccbdbc3102d554729892b952edc7a521bfedb7948031fb6ccfd72f4f7ed03834 - Sigstore transparency entry: 841173942
- Sigstore integration time:
-
Permalink:
Konthaina/khqr-python@6d7f4695f1003c41a69df8247fff2b2a61054eef -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/Konthaina
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6d7f4695f1003c41a69df8247fff2b2a61054eef -
Trigger Event:
push
-
Statement type:
File details
Details for the file konthaina_khqr-0.1.6-py3-none-any.whl.
File metadata
- Download URL: konthaina_khqr-0.1.6-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca0b186f3673ec9e9cb120bcf0de1b8b1b3540a34a16dbc7642e8ede47c67bf2
|
|
| MD5 |
8bd0195ffccfd52f0bbed25601ce7d8a
|
|
| BLAKE2b-256 |
ae927de4651f3e98aec2ea602169ec546930de88cfe04ec395725ab39f247d2a
|
Provenance
The following attestation bundles were made for konthaina_khqr-0.1.6-py3-none-any.whl:
Publisher:
publish.yml on Konthaina/khqr-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
konthaina_khqr-0.1.6-py3-none-any.whl -
Subject digest:
ca0b186f3673ec9e9cb120bcf0de1b8b1b3540a34a16dbc7642e8ede47c67bf2 - Sigstore transparency entry: 841173963
- Sigstore integration time:
-
Permalink:
Konthaina/khqr-python@6d7f4695f1003c41a69df8247fff2b2a61054eef -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/Konthaina
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6d7f4695f1003c41a69df8247fff2b2a61054eef -
Trigger Event:
push
-
Statement type: