Metadata-Version: 2.4
Name: konthaina-khqr
Version: 0.1.2
Summary: KHQR / EMVCo merchant-presented QR payload generator for Bakong (Cambodia), with CRC16 verification.
Author-email: Konthaina <konthaina87@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Konthaina
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/yourname/konthaina-khqr
Project-URL: Repository, https://github.com/yourname/konthaina-khqr
Project-URL: Issues, https://github.com/yourname/konthaina-khqr/issues
Keywords: khqr,bakong,emvco,qr,cambodia
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: qrcode
Requires-Dist: qrcode[pil]>=7.0; extra == "qrcode"
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: ruff>=0.6; extra == "dev"
Requires-Dist: mypy>=1.11; extra == "dev"
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: twine>=5.1; extra == "dev"
Dynamic: license-file

# 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

```bash
pip install konthaina-khqr
```

Optional: generate QR images (PNG) using `qrcode`:

```bash
pip install "konthaina-khqr[qrcode]"
```

## Quick start

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

```python
from konthaina_khqr import verify, decode

ok = verify(result.qr)
data = decode(result.qr)   # simple TLV decode
```

## CLI

```bash
khqr --type individual --bakong john_smith@devb --name "John Smith" --amount 1.25 --currency USD
```

Generate a PNG (requires extras):

```bash
khqr --type individual --bakong john_smith@devb --name "John Smith" --amount 1.25 --currency USD --png out.png
```

## Development

```bash
python -m venv .venv
. .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
pytest
ruff check .
mypy src
```

## Build & publish

Build:

```bash
python -m build
twine check dist/*
```

Publish to **TestPyPI**:

```bash
twine upload -r testpypi dist/*
```

Publish to **PyPI**:

```bash
twine upload dist/*
```

For GitHub Actions + Trusted Publishing, see `.github/workflows/publish.yml`.
