Skip to main content

KHQR / EMVCo merchant-presented QR payload generator for Bakong (Cambodia), with CRC16 verification.

Project description

English | ខ្មែរ

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]"

Features

  • Static & Dynamic KHQR
  • Correct KHR (116) / USD (840)
  • Stable static QR (no timestamp)
  • CRC-16 verification
  • Decode / verify helpers
  • CLI + PNG QR support

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

konthaina_khqr-0.1.7.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

konthaina_khqr-0.1.7-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file konthaina_khqr-0.1.7.tar.gz.

File metadata

  • Download URL: konthaina_khqr-0.1.7.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for konthaina_khqr-0.1.7.tar.gz
Algorithm Hash digest
SHA256 66cf83ea374b063d64cd968bcedbb03db947e4c618832c7a7502b86a904bac88
MD5 c6f73a3681e0390982847888a95ae46a
BLAKE2b-256 34fb94f1279ccede3a9e3ad1a52a89fd837da45110e8f0ac5bfb4048aced7e8f

See more details on using hashes here.

Provenance

The following attestation bundles were made for konthaina_khqr-0.1.7.tar.gz:

Publisher: publish.yml on Konthaina/khqr-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file konthaina_khqr-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: konthaina_khqr-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for konthaina_khqr-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 bd17b0d027cb96a581e7a0fb5384a43eaa7ea715a7d4506dce8d2caa764d0478
MD5 b789fff61b84d5535c454d4c92e81b28
BLAKE2b-256 7791e53933ba8feaeee8a5600fb9ea1169ad7b182ef663d646c35601d218525b

See more details on using hashes here.

Provenance

The following attestation bundles were made for konthaina_khqr-0.1.7-py3-none-any.whl:

Publisher: publish.yml on Konthaina/khqr-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page