Bakong KHQR SDK
Unofficial Rust SDK for Bakong KHQR
Features
- QR Code Generation (Individual & Merchant accounts)
- QR Code Decoding
- CRC16 Verification
- Bakong API Integration
- Support for KHR and USD currencies
Installation
Add to your Cargo.toml:
[]
= "0.1.0"
Quick Start
use ;
let khqr = new;
let info = builder
.bakong_account_id
.merchant_name
.merchant_city
.amount
.build
.unwrap;
let result = khqr.generate_qr.unwrap;
println!;
println!;
Examples
Run the examples:
# QR Generation
# QR Verification
# QR Decoding
# API - Check Account (requires token)
BAKONG_TOKEN=your_token
# API - Check Transaction (requires token)
BAKONG_TOKEN=your_token
API Reference
QR Generation
// Individual QR
let info = builder
.bakong_account_id
.merchant_name
.merchant_city
.currency // or "USD"
.amount // optional, omit for static QR
.build
.unwrap;
let result = khqr.generate_qr.unwrap;
// Merchant QR
let info = builder
.bakong_account_id
.merchant_id
.acquiring_bank
.merchant_name
.amount
.build
.unwrap;
let result = khqr.generate_merchant_qr.unwrap;
QR Verification
use ;
// Quick verification
let = verify_crc;
// Detailed verification
let result = verify.unwrap;
if result.is_valid
QR Decoding
use KHQRDecoder;
let decoded = decode.unwrap;
println!;
println!;
println!;
API Methods
// Check if Bakong account exists
let response = khqr.check_bakong_account.await?;
// Check transaction by MD5
let response = khqr.check_transaction_by_md5.await?;
// Generate payment deeplink
let response = khqr.generate_deeplink.await?;
Configuration
Sandbox (Default)
let khqr = new;
Production
use BakongConfig;
let khqr = with_config;
Custom Base URL
let khqr = with_config;
Environment
| Environment | URL |
|---|---|
| Sandbox | https://sit-api-bakong.nbc.gov.kh |
| Production | https://api-bakong.nbc.gov.kh |
Requirements
- A Bakong API token
- Register at https://api-bakong.nbc.gov.kh/ for sandbox access
- Contact Bakong for production access
Documentation
License
MIT License - see LICENSE for details.
Contributing
Contributions welcome! Please open an issue or PR on GitHub