Skip to main content

QR Pay

Create QR payment

QR PAY is a dynamic QR code generated per order with a built-in payment confirmation.

For each generated payment QR code, a virtual account number is also created and linked to a corresponding order.
When the customer makes a payment to this virtual account, the associated order is automatically marked as successfully paid.

When the customer pays to the virtual account number with the exact amount or exact amount and description,
Cas will confirm that your order has been paid.
Your system will receive a webhook of type TRANSACTIONS,
and the paymentMeta will contain the referenceNumber value associated with the QR Pay created earlier.

Steps to Integrate QR Pay

Below are the steps to integrate QR Pay into your product.

  1. Create a grant /grant/token with scopes set to qrpay.

  2. Open the Cas Link interface using the grantToken returned in the previous step. See details

  3. After the user completes the authentication, your frontend will receive a publicToken, which you can use to obtain an accessToken for the grant.

  4. Once you have the accessToken, call the Get QR Pay Account Identity API to verify if the account is valid.
    If the account is invalid, you should call the /grant/remove API to revoke the grant.

  5. You can now call the Create QR Pay API.

  6. Generate the QR code from the qrCode field in the response and display it in your interface.
    To simplify generating VietQR codes, you can use the Quicklink from vietqr.io to generate the QR code and embed the link into your system.

  7. Handle the order status in your system when receiving a transaction webhook,
    and the referenceNumber in the paymentMeta from the webhook corresponds to your internal order ID.

Call API

Create Grant Token for QR Pay

curl --location 'https://sandbox.bankhub.dev/grant/token' \
--header 'X-BankHub-Api-Version: 2023-01-01' \
--header 'x-client-id: <CLIENT_ID_HERE>' \
--header 'x-secret-key: <SECRET_KEY_HERE>' \
--header 'Content-Type: application/json' \
--data '{
"scopes": "qrpay",
"language": "vi",
"redirectUri": "https://your-domain.vn/link",
}'
info

For detail API, here

Get accessToken from publicToken

  curl --location 'https://sandbox.bankhub.dev/grant/exchange' \
--header 'X-BankHub-Api-Version: 2023-01-01' \
--header 'x-client-id: <CLIENT_ID_HERE>' \
--header 'x-secret-key: <SECRET_KEY_HERE>' \
--header 'Content-Type: application/json' \
--data '{
"publicToken": "bdbde2bad-7685-4f95-987c-71309a4a3"
}'
info

For detail API, here

Retrieve the Identity Information of the Account for QR Pay Creation

  curl --location 'https://sandbox.bankhub.dev/qr-pay/identity' \
--header 'X-BankHub-Api-Version: 2023-01-01' \
--header 'Authorization: <ACCESS_TOKEN_HERE>' \
--header 'x-client-id: <CLIENT_ID_HERE>' \
--header 'x-secret-key: <SECRET_KEY_HERE>'
info

For detail API, here

Create QR Pay

  curl --location 'https://sandbox.bankhub.dev/qr-pay' \
--header 'X-BankHub-Api-Version: 2023-01-01' \
--header 'Authorization: <ACCESS_TOKEN_HERE>' \
--header 'x-client-id: <CLIENT_ID_HERE>' \
--header 'x-secret-key: <SECRET_KEY_HERE>'
--data '{
"amount": 2000,
"description": "cassotest",
"referenceNumber": "1234455811acbc"
}'
info

For detail API, here