Bakong
Implement and troubleshoot Bakong KHQR payment flows from QR generation through payment-status reconciliation.
Quick Workflow
- Confirm integration mode: static KHQR, dynamic KHQR, or deeplink.
- Choose where QR is generated: merchant backend (recommended) or client SDK.
- Generate KHQR and capture
md5/hash metadata for status checks. - Display QR with clear expiration and enforce timeout handling.
- Obtain and maintain Open API token (
request_token->verify->renew_token). - Poll transaction status until success, fail, or QR timeout.
- Reconcile order state and notify the client UI.
Integration Rules
- Keep unique transaction IDs for each generated dynamic QR.
- Set QR expiration at or below 10 minutes for dynamic payment UX and polling control.
- Use MD5 status checks only for dynamic KHQR.
- Treat
not foundas retriable only while QR is still valid. - Stop polling when status is final (
successorfailed) or when QR expires. - Store enough metadata to retry checks (
md5, full hash, short hash, merchant/order IDs, expiry time).
Open API Flow
- Register integration via
POST /v1/request_token. - Verify code via
POST /v1/verifyand store issued token securely. - Renew token via
POST /v1/renew_tokenbefore expiry. - Check payment state using one of:
POST /v1/check_transaction_by_md5POST /v1/check_transaction_by_hashPOST /v1/check_transaction_by_short_hash
- Optionally use:
POST /v1/generate_deeplink_by_qrPOST /v1/check_bakong_account
Implementation Notes
- Generate and sign business-critical fields server-side where possible.
- Return only safe fields to clients (QR string/image, expiry, channel label, transaction reference).
- Add idempotency around order finalization to handle repeated status callbacks/polls.
- Log API request IDs, response code, and error code to simplify reconciliation.
- Keep environment-specific base URLs and tokens in secrets, never in client bundles.
Debugging Checklist
- Validate KHQR string format before showing it to users.
- Confirm token is active and not expired when calling status APIs.
- Verify
md5/hash was captured from the exact QR payload used by payer. - Confirm polling stops at expiry and marks timeout cleanly.
- Compare results across MD5 and full-hash endpoints when diagnosis is unclear.
References
- Open API endpoints and request/response examples:
references/open-api.md - KHQR SDK features and cross-platform usage notes:
references/khqr-sdk.md - End-to-end QR payment integration flow and operational notices:
references/qr-payment-integration.md - JavaScript
ts-khqrquick usage examples:references/ts-khqr-examples.md