# EMV Payment QR (PromptPay, KHQR, PayNow…) API

> Decode any EMVCo merchant QR (VietQR, PromptPay, KHQR, Lao QR, QRIS, DuitNow, PayNow, QR Ph, Pix) with CRC check, or create PromptPay, PayNow, KHQR.

- Endpoint: `GET | POST https://apibox.io.vn/v1/emv-qr`
- Category: Data & JSON
- HTML docs: https://apibox.io.vn/docs/emv-qr/ (Vietnamese: https://apibox.io.vn/vi/docs/emv-qr/)
- Online tool: https://apibox.io.vn/tools/emv-qr/
- Authentication: `Authorization: Bearer <API key>` or `X-API-Key: <API key>` (free key: https://apibox.io.vn/dashboard/#signup)

`action=decode` with a `payload` (the text inside the QR; decode an image first with `/v1/qr-decode`) splits the EMVCo merchant-presented TLV tree, checks the CRC-16 of field 63 and the mandatory fields, and detects the scheme from the identifier in fields 26–51: VietQR / NAPAS 247, PromptPay (Thailand), KHQR / Bakong (Cambodia), Lao QR (LAPNet), QRIS (Indonesia), DuitNow (Malaysia), PayNow / SGQR (Singapore), QR Ph, FPS (Hong Kong), Pix and UPI. It returns the merchant name and city, category code, amount, currency (ISO 4217), tip / fee settings, additional data (bill number, reference, terminal…), the language template and scheme details such as the PromptPay proxy, the PayNow UEN or the Bakong account. `payable_from_vietnam` says whether Vietnamese bank apps can pay the code through the NAPAS cross-border QR links (Thailand, Cambodia, Laos, China).

`action=create` builds a payload with the right CRC: `scheme=promptpay` (`proxy` = Thai mobile, 13-digit ID or e-wallet ID), `paynow` (mobile or UEN, `editable`, `expiry`), `khqr` (`bakong_account_id`, `merchant_name`, KHR or USD, creation / expiry timestamps), `vietqr` (`bank`, `account`) or `generic` with any tags in `fields`. Add `amount`, `merchant_name`, `merchant_city`, `bill_number`, `reference`… Add `format=png`, `svg` or `json_image` to get the QR image from the `qr` engine (size, colour, margin parameters).

Scheme identifiers come from the central bank / scheme documents; Lao QR and QR Ph are detected from observed codes (marked `confidence: observed`). `action=schemes` lists them.

## Parameters

| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
| `action` | body|query | string | no |  | `decode` (default when `payload` is given), `create` or `schemes`. Also as a path: /v1/emv-qr/decode. |
| `payload` | body|query | string | no |  | EMVCo QR text to decode (also accepts upi:// links). |
| `scheme` | body|query | string | no |  | For create: `promptpay`, `paynow`, `khqr`, `vietqr` or `generic`. |
| `proxy` | body|query | string | no |  | PromptPay mobile / ID / e-wallet ID, PayNow mobile or UEN. |
| `bakong_account_id` | body|query | string | no |  | KHQR Bakong account, e.g. `john_smith@aclb`. |
| `bank` | body|query | string | no |  | VietQR: bank code, name or BIN (with `account`). |
| `amount` | body|query | number | no |  | Amount (makes a dynamic QR). |
| `currency` | body|query | string | no |  | KHQR only: `KHR` (default) or `USD`. |
| `merchant_name` | body|query | string | no |  | Merchant name (ASCII, max 25). |
| `merchant_city` | body|query | string | no |  | Merchant city (max 15). |
| `bill_number` | body|query | string | no |  | Additional data: bill number; also `reference`, `store_label`, `terminal_label`, `mobile_number`, `purpose`. |
| `fields` | body | object | no |  | Generic create: EMV tags, templates as nested objects, e.g. `{"26": {"00": "SG.PAYNOW", …}, "52": "0000"}`. |
| `format` | body|query | string | no |  | Create: `png`, `svg` or `json_image` to also render the QR (default JSON payload only). |

## Example request

```bash
curl -X POST "https://apibox.io.vn/v1/emv-qr" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action":"decode","payload":"00020101021229370016A0000006770101110113006681234567853037645402505802TH5913Coffee Corner6007Bangkok63040854"}'
```

## Example response

```json
{
  "format": "emv_mpm",
  "valid": true,
  "emv_complete": false,
  "crc": {
    "present": true,
    "value": "0854",
    "expected": "0854",
    "valid": true
  },
  "payload_format_indicator": "01",
  "initiation": "dynamic",
  "scheme": {
    "id": "promptpay",
    "name": "PromptPay / Thai QR Payment",
    "country": "TH",
    "operator": "NITMX / Bank of Thailand",
    "confidence": "documented"
  },
  "merchant_accounts": [
    {
      "tag": "29",
      "guid": "A000000677010111",
      "scheme": {
        "id": "promptpay",
        "name": "PromptPay / Thai QR Payment",
        "country": "TH",
        "operator": "NITMX / Bank of Thailand",
        "confidence": "documented"
      },
      "details": {
        "type": "mobile",
        "proxy": "0066812345678",
        "mobile": "0812345678"
      },
      "sub": [
        {
          "id": "00",
          "value": "A000000677010111"
        },
        {
          "id": "01",
          "value": "0066812345678"
        }
      ]
    }
  ],
  "merchant": {
    "name": "Coffee Corner",
    "city": "Bangkok",
    "country": "TH"
  },
  "amount": 50,
  "currency": {
    "numeric": "764",
    "code": "THB"
  },
  "tip": null,
  "additional_data": null,
  "language_template": null,
  "payable_from_vietnam": {
    "domestic": false,
    "napas_link": "Thailand (PromptPay) - live since 2024",
    "note": "Payable from Vietnamese bank apps that joined the NAPAS cross-border QR programme; the amount is converted by your bank."
  },
  "warnings": [
    "Mandatory field 52 (merchant_category_code) is missing"
  ],
  "fields": [
    {
      "id": "00",
      "name": "payload_format_indicator",
      "length": 2,
      "value": "01"
    },
    {
      "id": "01",
      "name": "point_of_initiation",
      "length": 2,
      "value": "12"
    },
    "…"
  ]
}
```

## Use cases

- Check that a QR sticker at a shop really pays the expected merchant (anti-swap)
- Accept tourists’ PromptPay, KHQR and Lao QR codes in a Vietnamese POS or app
- Generate PromptPay or PayNow QR codes for invoices and receipts
- Debug CRC and field errors in QR codes produced by your own system

## FAQ

### Can it read a QR image?

This endpoint works on the payload text. Decode the image first with /v1/qr-decode, then send the text here.

### Which foreign codes can Vietnamese banking apps pay?

Through NAPAS links: Thai PromptPay, Cambodian KHQR, Lao QR and UnionPay QR from China (with participating banks). The response flags this in payable_from_vietnam.

### Is the payment executed?

No. The API only reads and builds QR payloads; nothing is sent to any bank.
