Skip to main content

A Python package for Bakong KHQR payment integration using the BakongV2 API. (Unofficial)

Project description

bakong-v2

A Python package for Bakong KHQR payment integration using the BakongV2 API. (Unofficial)

Installation

pip install bakong-v2

Quick Start

from bakong_v2 import KHQR

# Get your token at https://t.me/bakong_relay_bot
k = KHQR("your_token_here")

# Generate QR code
qr = k.create_qr(
    bank_account="your_account@bank",
    merchant_name="Your Store",
    merchant_city="Phnom Penh",
    amount=10.50,
    currency="USD",
)
print(qr)

# Check payment status
status = k.check_payment("your_md5_hash")
print(status)  # "PAID" or "UNPAID"

# Generate MD5
md5 = k.generate_md5(qr)
print(md5)

# Check Bakong account
account_info = k.check_account("user@bank")
print(account_info)

# Generate deeplink
link = k.generate_deeplink(qr)
print(link)

API Reference

All methods send POST requests to https://bakong-v2.vercel.app/api/v2/bakong/ with your token as a query parameter.

create_qr(bank_account, merchant_name, merchant_city, amount, currency, ...)

Generate KHQR payment string.

generate_md5(qr)

Generate MD5 hash from a QR string.

check_payment(md5)

Check payment status by MD5 hash. Returns "PAID" or "UNPAID".

get_payment(md5)

Get payment details by MD5 hash. Returns transaction dict or None.

check_account(account_id)

Check if a Bakong account exists.

check_payment_by_hash(hash)

Check payment by full transaction hash.

check_payment_by_short_hash(hash, amount, currency)

Check payment by short hash (8 chars).

check_payment_by_instruction_ref(ref)

Check payment by instruction reference.

check_payment_by_external_ref(ref)

Check payment by external reference.

check_bulk_payments(md5_list)

Check multiple payments by MD5 hashes (max 50).

check_bulk_payments_by_hash(hash_list)

Check multiple payments by full hashes (max 50).

generate_deeplink(qr, ...)

Generate a Bakong deep link from a QR string.

qr_image(qr, format, output_path)

Generate QR code image.

Requirements

  • Python >= 3.10
  • No external dependencies required (uses only standard library)

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

bakong_v2-1.1.0.tar.gz (202.6 kB view details)

Uploaded Source

Built Distribution

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

bakong_v2-1.1.0-py3-none-any.whl (207.4 kB view details)

Uploaded Python 3

File details

Details for the file bakong_v2-1.1.0.tar.gz.

File metadata

  • Download URL: bakong_v2-1.1.0.tar.gz
  • Upload date:
  • Size: 202.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for bakong_v2-1.1.0.tar.gz
Algorithm Hash digest
SHA256 f9442004ff6045cf032c33e7fed948b276bb74b3b1f47b72bfa655e2f8417f83
MD5 12efa12b385251aa100a3e020ceb0029
BLAKE2b-256 b879fa258faa2e38ca9ecb6e86d6f0b07b51c720b852b0e6615e791d44eb640b

See more details on using hashes here.

File details

Details for the file bakong_v2-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: bakong_v2-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 207.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for bakong_v2-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7bd0d32313eb5ba6aa538e182a58f000e432dd25a3e7afbdf7401522df294925
MD5 918461da3d49c1c700c43ab601f49538
BLAKE2b-256 e05e5763a9a830f3d42f213d4833fc4b54dc71022b5ff0d651991a336cec440c

See more details on using hashes here.

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