# E-Invoice & E-WayBills: Generate Payment QR Code

This API is used to generate the dynamic QR code for B2C invoices to support online UPI payment.

## URL

```
POST https://cloud.octagst.com/api/octa/einvoice/generatepaymentqrcode
```

## Query Parameters

| Name            | Description                                                          | Type     | Value                          |
| --------------- | -------------------------------------------------------------------- | -------- | ------------------------------ |
| `qrcode`        | Specify `yes` to include QR Code image in response                   | Optional | `yes`, `no` (Default)          |
| `qrcodeformat`  | Specify QR code image format                                         | Optional | `PNG` (Default), `JPEG`, `GIF` |
| `qrcodequality` | Specify QR code image quality                                        | Optional | `standard`, `high` (Default)   |
| `pdf`           | Specify `yes` to include e-invoice pdf and e-waybill pdf in response | Optional | `yes`, `no` (Default)          |

## Request Payload

Request payload should contain the JSON encoded invoice data. This payload is similar to the `Generate IRN` API with the
only difference of supply type which has to be set to `B2C`.

```json
{
  //...
  "TranDtls": {
    "SupTyp": "B2C"
    //...
  },
  //...
  "BuyerDtls": {
    "Gstin": null
    //...
  }
  //...
}
```

## Success Response

Response payload will contain the success status along with IRN information.

### Structure

| Parameter       | Data Type                               | Description                                                  |
| --------------- | --------------------------------------- | ------------------------------------------------------------ |
| Success         | Boolean                                 | `true` in case of success                                    |
| QRCodeImagePng  | String (Binary data in Base64 encoding) | e-Invoice QR code PNG image                                  |
| QRCodeImageJpeg | String (Binary data in Base64 encoding) | e-Invoice QR code JPEG image                                 |
| QRCodeImageGif  | String (Binary data in Base64 encoding) | e-Invoice QR code GIF image                                  |
| PaymentQrCode   | String (Binary data in Base64 encoding) | Contents of dynamic QR code                                  |
| **Errors**      | Error[]                                 | List of errors, will be present only when Success is `false` |

**Error Object:**

| Parameter | Data Type | Description   |
| --------- | --------- | ------------- |
| Code      | String    | Error Code    |
| Message   | String    | Error message |

### Sample – Success

```json
{
  "Success": true,
  "QRCodeImagePng": "iVBORw0KGgoAAAANSUhEUgAAAHIAAAB...IPwEIVCUYnlSs/gAAAABJRU5ErkJggg==",
  "PaymentQrCode": "upi://pay?pa=blowbits@ybl&pn=BLOWBITS%20SOLUTIONS%20LLP&tn=SELLER:08AASFB9647G1ZU%20NO:B2C1617260496%20DT:01-04-2021%20Taxable:%e2%82%b95000%20IGST:%e2%82%b9900&am=5900&cu=INR&mode=01"
}
```

### Sample – Failure

If the API request fails for some reasons, the response payload will contain the failure status and a list of errors.

```json
{
  "Success": false,
  "Errors": [
    {
      "Code": "ERR_CODE_1",
      "Message": "ERR MESSAGE 1"
    },
    {
      "Code": "ERR_CODE_n",
      "Message": "ERR MESSAGE n"
    }
  ]
}
```