---
title: Generate QR
description: Generate dynamic QR codes for UPI payment transactions.
---

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/pay/v4/api/generateorder/?token=<access_token>
```

## Header

| Parameter | Type Value | Description | Value Like |
| --- | --- | --- | --- |
| Content-Type  required | String | The Content-Type header indicates the media type of the request or response body so the receiver knows how to process the data. | `application/json` |

## Request Body

| Parameter | Type Value | Description | Value Like |
| --- | --- | --- | --- |
| orderid  required | Alphanumeric  <br>(1-30) | Merchant generated transaction id | `ORD1234` |
| amount  required | Numeric  <br>(1-10 .2) | Amount with two decimals | `100.00` |
| tid  optional | String  <br>(15) | Terminal id of pos devices |
| buyer_email  required | Email  <br>(3-50) | Buyer Email | `customer@example.com` |
| buyer_phone  required | Numeric  <br>(8-15) | Buyer Phone | `99999999` |
| mer_dom  optional | Alphanumeric | Base64 encoded merchant domain. | `aHR0cDovL2xvY2FsaG9zdA==` |
| customvar  optional | Alphanumeric|Space|Equal  <br>(1-4096) | Any customized info affiliate can pass |
| call_type  required | String  <br>(1-20) | Use upiqr to generate QR | `upiqr` |
| customer_consent  required | chars  <br>(1) | Consent flag to be sent by Merchant.<br>Allowed values:  `Y`,   `N` | `Y` |

## Success 200

| Parameter | Type Value | Description | Value Like |
| --- | --- | --- | --- |
| qrcode_string  required | String | QR Code String | `upi://pay?pa=example@icici&pn=Adam%20Innovations%20Test&cu=INR&tn=Pay to Adam Int&am=1.00&mc=5045&mode=04&tr=APS17722152&td=APS17722152` |
| ap_transactionid  required | String | Transaction Identifier | `17722152` |
| status  required | String | Status Code | `200` |

## PHP

```php
 <?php
$merchant_id   = "<merchant_id>";
$username      = "<username>";
$password      = "<password>";
$secret        = "<secret>";
$secretKey     = '<secretKey>';
$data = array();
$data['orderid'] = "ORD123456";
$data['amount'] = "1000.00";
$data['buyer_email'] = "customer@example.com";
$data['buyer_phone'] = "99999999";
$data['call_type'] = "upiqr";

$privatekey = hash('sha256', $secret.'@'.$username.':|:'.$password);
$encdata	   = encrypt(json_encode($data), $secretKey);
$checksum   = checksum($data);

$payload    = [
                'merchant_id'=>$merchant_id,
	            'encdata' => $encdata,
	            'checksum' => $checksum,
                'privatekey' => $privatekey
              ];

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://kraken.airpay.co.in/airpay/pay/v4/api/generateorde/r?token=<access_token>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $payload
));

$result = curl_exec($curl);

curl_close($curl);
$response = json_decode($result)->response;
```

### Success Response

```json
HTTP/1.1 200 OK
 {
    "status_code": "200",
    "response_code": "00",
    "status": "Success",
    "message": "success",
    "data": {
         "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",
         "ap_transactionid":"17722152",
         "status":"200"
    }
}
```

### Error Response

```json
 HTTP/1.1 200 OK
 {
  {
    "status_code":"400",
    "response_code":501,
    "status":"fail",
    "message":"Invalid Merchant Id",
    "data":[]
   }
}
```