Generate KHQR Code
Short reference for creating a payment KHQR code.
Endpoint: POST /khqr/generate
Auth Headers
http
x-auth-type: api-key
x-api-key: <your-api-key>
Content-Type: application/jsonRequest Body
| Field | Type | Req | Notes |
|---|---|---|---|
| amount | number | Yes | > 0 |
| currency | number | Yes | 840 = USD, 116 = KHR |
| expiredAfter | number | Yes | ms until expiry (e.g. 30000) |
| meta | object | No | Arbitrary key/values (echoed + webhook) |
Minimal Example
json
{
"amount": 1,
"currency": 840,
"expiredAfter": 30000,
"meta": { "orderId": "ORD-123" }
}cURL
bash
curl --location 'http://localhost:3000/khqr/generate' \
--header 'x-auth-type: api-key' \
--header 'Content-Type: application/json' \
--header 'x-api-key: <your-api-key>' \
--data '{
"amount": 1,
"currency": 840,
"expiredAfter": 30000,
"meta": { "orderId": "ORD-123" }
}'Success Response (Example)
json
{
"transactionId": "b34524dd-6998-411c-bcd6-51f181460dbb",
"expiredAt": "2025-08-10T07:26:30.693Z",
"status": "PENDING",
"requestData": {
"amount": 1,
"currency": 840,
"expiredAfter": 30000,
"meta": { "orderId": "ORD-123" }
},
"data": {
"qr": "00020101021229...",
"md5": "630d3230a992c502d760f13260c3c414"
}
}Status Values
PENDING | SUCCESS | EXPIRED | FAILED
Notes
- Keep expiry short for dynamic, longer (<=5m) for static.
- Store
transactionId/md5to reconcile or check status (/khqr/check). metais returned unchanged in webhook payload.
Related
Last updated: August 10, 2025
