Skip to content

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/json

Request Body

FieldTypeReqNotes
amountnumberYes> 0
currencynumberYes840 = USD, 116 = KHR
expiredAfternumberYesms until expiry (e.g. 30000)
metaobjectNoArbitrary 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 / md5 to reconcile or check status (/khqr/check).
  • meta is returned unchanged in webhook payload.

Last updated: August 10, 2025