Generate an ABA PayWay KHQR
Use this endpoint to create a dynamic KHQR that can be scanned by ABA Mobile or another KHQR-compatible banking app. The transaction is stored by PhkaPay and monitored until it succeeds or expires.
Prerequisites
Create a PayWay merchant configuration and a pw_ API key in the dashboard. The key must be linked to that configuration.
Generate a QR
POST /payway/generate-qr
Content-Type: application/json
x-api-key: <your-payway-api-key>
x-auth-type: api-payway{
"qrData": {
"orderId": "order_001",
"amount": 1,
"currency": "USD",
"firstName": "Sokha",
"lastName": "Chan",
"email": "customer@example.com",
"phone": "012345678",
"items": [{ "name": "Coffee", "quantity": 1, "price": 1 }],
"lifetime": 6,
"qrImageTemplate": "template3_color"
},
"metaData": { "cartId": "cart_123" }
}orderId must be unique and no longer than 20 characters. currency supports USD and KHR; the minimum is 0.01 USD or 100 KHR. lifetime is expressed in minutes, accepts 3–172800 minutes, and defaults to 6 in PhkaPay. Customer fields, items, metadata, and the image template are optional.
curl --request POST 'https://phka-pay.rikrey.com/payway/generate-qr' \
--header 'Content-Type: application/json' \
--header 'x-api-key: YOUR_PAYWAY_API_KEY' \
--header 'x-auth-type: api-payway' \
--data '{
"qrData": {
"orderId": "order_001",
"amount": 1,
"currency": "USD",
"lifetime": 6
}
}'const response = await fetch("https://phka-pay.rikrey.com/payway/generate-qr", {
method: "POST",
headers: {
"content-type": "application/json",
"x-api-key": process.env.PAYWAY_API_KEY,
"x-auth-type": "api-payway",
},
body: JSON.stringify({
qrData: {
orderId: "order_001",
amount: 1,
currency: "USD",
lifetime: 6,
},
}),
});
const payment = await response.json();Response
{
"transactionId": "PW20260711123456ABCD",
"orderId": "order_001",
"qrString": "000201010212...",
"qrImage": "data:image/png;base64,...",
"deeplink": "abamobilebank://ababank.com?...",
"appStore": "https://itunes.apple.com/...",
"playStore": "https://play.google.com/...",
"amount": 1,
"currency": "USD",
"status": "CHECKOUT",
"gatewayStatus": { "code": "0", "message": "Success." },
"expiresAt": "2026-07-11T05:40:00.000Z"
}Render qrString with a standards-compliant QR component or display qrImage. On mobile, use deeplink to open ABA Mobile. Stop accepting payment when expiresAt is reached.
Check payment status
Use the same status endpoint as hosted PayWay checkout. The API key may only query transactions that it created.
curl --request POST 'https://phka-pay.rikrey.com/payway/check-status' \
--header 'Content-Type: application/json' \
--header 'x-api-key: YOUR_PAYWAY_API_KEY' \
--header 'x-auth-type: api-payway' \
--data '{"transactionId":"PW20260711123456ABCD"}'You may send orderId instead of transactionId. Poll every few seconds until status becomes SUCCESS, FAILED, or EXPIRED. For production integrations, configure a PayWay webhook as the authoritative notification and use polling for user-interface updates.
{
"transactionId": "PW20260711123456ABCD",
"orderId": "order_001",
"status": "SUCCESS",
"amount": "1.00",
"currency": "USD",
"expiredAt": "2026-07-11T05:40:00.000Z",
"createdAt": "2026-07-11T05:34:00.000Z"
}Error handling
400— invalid request, duplicate order ID, missing PayWay configuration, or PayWay rejected the request.401— missing or invalid PayWay API key.404— transaction not found for the requesting key.502— PayWay could not be reached or returned an invalid response.
