Metadata-Version: 2.4
Name: cambodia-bank
Version: 1.0.3
Summary: Dependency-free KHQR toolkit for Cambodia (Bakong, TrueMoney TRMC, ABA).
Keywords: khqr,bakong,truemoney,trmc,aba,cambodia,qrcode
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Provides-Extra: image
Requires-Dist: qrcode[pil]>=7; extra == "image"

# cambodia_bank

A tiny, dependency-free KHQR toolkit for Cambodia. Generate payment QR codes
and verify payments for **Bakong** and **ABA** — no third-party SDK required.

## Install

```bash
pip install cambodia_bank
```

Optional extra for rendering QR images:

```bash
pip install "cambodia_bank[image]"
```

## Quick start

```python
from cambodia_bank import KHQR

khqr = KHQR()
```

### Bakong

```python
qr = khqr.create_qr(
    bank="bakong",
    account_id="eh_theng@bkrt",
    merchant_name="Leurizz Store",
    amount=1,
    currency="USD",      # "USD" or "KHR"
)

print(qr)
```

### ABA

```python
qr = khqr.create_qr(
    bank="abakhqr",
    payment_link="https://link.payway.com.kh/ABAPAYxxxx",
    amount=1,
)

print(qr)
```

`print(qr)` outputs a JSON response containing the `qr` string and its `md5`
hash (or `tran_id` / `client_id` for ABA).

## Verify a payment

```python
# Bakong — check by md5 hash
status = khqr.check_payment(md5="<32-char md5>")

# ABA — check by tran id + client id
status = khqr.check_payment(tran_id="<tran_id>", client_id="<client_id>")

print(status)
```

The bank is detected automatically from the arguments you pass.

- **Bakong** checks hit a hosted check service
  (`https://cambodia-bank.zorost4re.com/check`). Override it with the
  `BAKONG_CHECK_URL` environment variable, or pass a Bakong developer token
  (`KHQR(bakong_token="...")`) to use the official Bakong Open API.
- **ABA** checks hit the ABA PayWay API using the `tran_id` and `client_id`
  that came with the generated QR.

## License

MIT
