---
page_source: https://juspay.io/in/docs/upi-qr-code/docs/scan--pay/transaction-api
page_title: Transaction API
---


# Transaction API



When customers select the UPI QR Code payment option, merchants have to call the below transaction API. From the transaction API response, merchants will use the sdk_params for constructing the URI, which will be utilized for generating the QR code. The customer scans the QR code using the UPI app installed on their device and completes the payment.

Basic Parameters


### Payload
- **Order_id**:
  - Description: `order_id` pertaining to the order for which the payment is started.
  - Tags: String, Mandatory
- **Merchant_id**:
  - Description: ID of the merchant_account that you hold with us.
  - Tags: String, Mandatory
- **Payment_method_type**:
  - Description: Must be `UPI`
  - Tags: String, Mandatory
- **Payment_method**:
  - Description: Must be `UPI`
  - Tags: String, Mandatory
- **Txn_type**:
  - Description: Must be `UPI_QR`
  - Tags: String, Mandatory
- **Redirect_after_payment**:
  - Description: This is a boolean variable and accepts true/false. We recommend that you set this to true. If set to `true`, then the user is redirected to the `return\_url` configured for the order. If set to `false`, then the user will be stopped at the response page from the gateway. Your client should be able to read the page/title to infer that the user has completed the transaction.
  - Tags: String, Mandatory
- **Format**:
  - Description: If it is set to `json`, then the response will be HTTP 200 with a JSON formatted text. Otherwise, the response is HTTP 302 with the Location attribute having the destination URL.
  - Tags: String, Mandatory
- **Sdk_params**:
  - Description: Must be `true`
  - Tags: Boolean, Mandatory



### **Construction of UPI Pay String code through the string mentioned** 



The sdk_params obtained in the response of the UPI transaction call should be used for constructing the Intent URI.

**Sample URI:** upi://paytr=202101345671229366&tid=121313202101345671229366&pa=juspay@axisbank&mc=1234&pn=Merchant%20Inc&am=1.00&cu=INR&tn=Pay%20for%20merchant

**Format:** upi://pay?tr=...(enter the tr).......&tid=...(enter the tid).......&pa=.....(enter merchant_vpa)...&mc=....(enter the mcc)...&pn=....(enterthe Merchant name)...&am=.....(enter the amount).....&cu=INR&tn=....(description for the transaction)..

> **Warning**
> In the URI spaces are replaced by "%20". The URI is encoded. Kindly generate the intent URI dynamically ie, based on the params received in the sdk_params response. Do not hardcode any keys or values as it can differ with different PG’s.For example, if you do not receive the "tid" value in the transaction API response, you would need to exclude the "tid" parameter in the URI.
> 
> _URI Format without tid:_ 
> 
> **upi://pay?tr=...(enter the tr).......&pa=.....(enter merchant_vpa)...&mc=....(enter the mcc)...&pn=....(enter** **the Merchant name)...&am=.....(enter the amount).....&cu=INR&tn=....(description for the transaction)..** 



> **Note**
> UPI QR Code image generation has to be completely handled by the merchant. Once the URI is generated, merchants have to create the UPI QR Code image with the generated URI.
> 
> There are several Js libraries that help in generating QR code.
> 
> Sample library : [https://www.npmjs.com/package/qrcode](https://www.npmjs.com/package/qrcode)



## Sample Code Snippets:
### Sample Request:

#### Request Code Snippet:

```request
curl -X POST https://api.juspay.in/txns \
-d "order_id=9727125664Q20200107180320" \
-d "merchant_id=juspay" \
-d "payment_method_type=UPI" \
-d "payment_method=UPI" \
-d "txn_type=UPI_QR"
-d "redirect_after_payment=true" \
-d "format=json"\
-d "sdk_params=true"\

```

### Sample Response:

#### Response:
```json
{
  "txn_uuid": "eulgxNx4mgcnKwoqe2",
  "txn_id": "9727125664Q20200107180320",
  "status": "PENDING_VBV",
  "payment": {
    "sdk_params": {
      "tr": "202101345671229366",
      "tid": "121313202101345671229366",
      "merchant_vpa": "juspay@axisbank",
      "merchant_name": "juspay",
      "mcc": "1234",
      "amount": "1"
    },
    "authentication": {
      "url": "https://api.juspay.in/v2/pay/start/juspay/eulgxNxxxxcnKwoqe2",
      "method": "GET"
    }
  },
  "order_id": "9727125664Q20200107180320"
}

```

