# Generate Upi payment link

This API generates a UPI payment link that customers can use to make payments directly. The generated link can also be converted into a QR code for ease of use.

####

#### **Method**

```
POST https://api.ninjapay.me/webextension/api/v1/fiat/realtime-payment-link/generate-link
```

#### **Parameters**

* **link\_id**: `String` - Payment link id, generate on create real time payment link(required)
* **phone**: `String` - Phone number of customer.
* **email**: `String` - Email of customer.
* **amount**: `Number` - Amount of pay link need to generate.(required)
* **vpa\_id** : `String` - Pass vpa id in case of upi intent.
* **tip**: `Number` - Extra amount which customer wants to paid for service.

| Parameters      | Important points                                                                                              |
| --------------- | ------------------------------------------------------------------------------------------------------------- |
| amount          | Amount can pass less than payment link amount only when partial is true                                       |
| tip and amount  | Both are different, amount doesnt include tip.                                                                |
| phone and email | If phone or email is passed,  then form will come prefill to customer when they click on payment link to pay. |

```javascript

Body (application/json)
 {

    "link_id": "Link id of payment link",
    "phone": "1234567891",
    "email": "example@gmail.com",
    "amount": 100,
    "vpa_id": "",
    "tip": 0
}

```

#### **Response**

```json
{
    "status": true,
    "data": {
        "order_id": "FT_RTPLCFItk2hQzqfG3Pxbp4YG",
        "payment_uri": "upi://pay?pa=paytm-69551323@paytm&pn=MEDININ%20HEALTH%20TECH%20PRIVATE%20LIMITED&mc=8011&tid=PYTM40806804710516286497&tr=40806804710516286497&am=1&cu=INR",
        "qr_base64_img": "",
        "expiry_date": "2024-08-06 11:48:48"
    },
    "message": "Payment link here !"
}
```

#### **Code Example**

{% code overflow="wrap" %}

```javascript

const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key':'API_KEY'
  },
  body: '{ "link_id": "Link id of payment link",    "phone": "1234567891",
    "email": "example@gmail.com", "amount": 100, "vpa_id": "",  "tip": 0}'
};

fetch('https://api.ninjapay.me/webextension/api/v1/fiat/realtime-payment-link/link/generate-link', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
  
```

{% endcode %}
