---
title: Generate QR
description: This API is for generating Dynamic QR: QR that is generated each time for a new transaction for UPI payments.
---

# UPI - Generate QR

This API is for generating Dynamic QR: QR that is generated each time for a new transaction for UPI payments. Thus, the merchant will be adding amount needed to be paid by customer before generating the QR for each transaction. Once the payment is successful, the QR will be expired.

## post

```
https://kraken.airpay.co.in/airpay/api/generateOrder
```

## Header

| Field | Type | Description |
| --- | --- | --- |
| Content-Type | String | application/json |

## Parameter

| Field      | Type    | Required | Description                                                                                                                                                                                                                                                                                                              |
| ---------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| mercid     | int     | Yes      | Merchant ID (length 1-20)                                                                                                                                                                                                                                                                                                |
| orderid    | String  | Yes      | Unique reference number (length 1-30)                                                                                                                                                                                                                                                                                    |
| amount     | Decimal | Yes      | Amount with two decimals (length 1-6 .2)                                                                                                                                                                                                                                                                                 |
| tid        | String  | No       | Terminal id of POS devices (length 15)                                                                                                                                                                                                                                                                                   |
| buyerPhone | String  | Yes      | Consumer mobile number (length 10)                                                                                                                                                                                                                                                                                       |
| buyerEmail | String  | Yes      | Consumer email id (length 5-50)                                                                                                                                                                                                                                                                                          |
| mer_dom    | String  | Yes      | Merchant whitelisted domain passed as `base64_encode` (length 64)                                                                                                                                                                                                                                                        |
| customvar  | String  | No       | Any customized info affiliate can pass. Additional values need to be passed with `\|` separator (length 10-100)                                                                                                                                                                                                          |
| call_type  | String  | Yes      | Use `upiqr` to generate QR (length 1-20)                                                                                                                                                                                                                                                                                 |
| checksum   | String  | Yes      | Checksum generation:<br>Key generated by : `key256 = hash('SHA256', username."~:~".password);`<br>`alldata = mercid.orderid.amount.tid.buyerPhone.buyerEmail.mer_dom.customvar.call_type;`<br>Checksum generated by : `checksum = hash('SHA256', key256.'@'.alldata.date('Y-m-d'));`                                     |
| encData    | String  | Yes      | Convert `alldata` to JSON and encrypt using AES-256-CBC algorithm with `EncryptionKey`.<br>`IV = bin2hex(openssl_random_pseudo_bytes(8));`<br>`raw = openssl_encrypt(json_data, AES-256-CBC, EncryptionKey, OPENSSL_RAW_DATA, IV);`<br>`encData = IV.base64_encode(raw);`<br>`EncryptionKey` will be provided by Airpay. |

## Request-Example:

```
{
    "encData": "eyJtaWQiOiIxODk5OSIsInZlcnNpb24iOiJ2MSIsInRpZCI6IiIsInJlZl91cmwiOiIiLCJjaGVja3N1bSI6IiIsIm1lcl9kb20iOiJhSFIwY0RvdkwyeHZZMkZzYUc5emRBPT0iLCJzdXJjaGFyZ2VfYW10IjoiIiwiY3VzdG9tdmFyIjoiIiwiY2FsbF90eXBlIjoidXBpcXIiLCJ1cGlfbW9kZSI6InFyX2NvZGUifQ==",
    "checksum": "f3c28b55c93a3f1090e0b6fcc1f9f0a1735c0267de29893f20ded51c71e6de20",
    "mercid": "767807"
}
```

## Success 200

| Field | Type | Description |
| --- | --- | --- |
| data | String | Data will in encrypted format, decrypt it AES-256-CBC algorithm using EncryptionKey<br>IV = substr(encryptedData, 0, 16);<br>data = substr(encryptedData, 16);<br>DecryptedData = openssl_decrypt(base64_decode(data), AES-256-CBC, EncryptionKey, options=OPENSSL_RAW_DATA, IV); EncryptionKey Airpay will be provide this value. |

## Encrypted Response-Example:

```
{
    "data": "zdXJfbW9kZSI6InFyX2NveyJtaWQiOiIxODk5OSIsInZlcnNpb24iOiJ2MSIsInRpZCI6IiIsInJlZl91cmwiOiIiLCJjaGVja3N1bSI6IiIsIm1lcl9kb20iOiJhSFIwY0RvdkwyeHZZMkZzYUc5emRBPT0iLCJzdXJjaGFyZ2VfIjoiIiwiY2FsbF90eXBlIjoidXBpcXIiLCJ1cGlfbW=="
}
```
## Decrypted Response-Example:
```
{
    "QRCODE_STRING": "upi://pay?pa=example@icici&pn=Adam%20Innovations%20Test&cu=INR&tn=Pay to Adam%20Innovations%20Test&am=1.00&mc=5045&mode=04&tr=APS17722152&td=APS17722152",
    "MID": 18999,
    "RID": 17722152,
    "status": 200
}
```