# webUPI.sendPaymentToLightning()

Request that the user sends a UPI payment that will be converted into a Lightning Network payment. The web app provides a BOLT-11 invoice and a callback URL. The function will return an acknowledgment if the payment initiation is successful.

#### Method

```jsx

async function sendPaymentToLightning(args: SendPaymentToLightningArgs): SendPaymentToLightningResponse;

```

#### Parameters

```jsx

interface SendPaymentToLightningArgs {
  invoice: string; // The BOLT-11 invoice for the Lightning Network payment
  callbackUrl: string; // The URL that the UPI app or cryptocurrency exchange will notify upon completion of the payment
}

```

#### Response

```jsx

interface SendPaymentToLightningResponse {
  acknowledgment: string; // A message acknowledging the initiation of the payment
}

```

#### Code Example

```jsx

try {
    const paymentArgs = {
        invoice: 'lnbc100...', // BOLT-11 invoice provided by the merchant
        callbackUrl: '<http://example.com/callback>' // URL to send a notification to when the payment has been processed
    };
    const response = await webUPI.sendPaymentToLightning(paymentArgs);
    console.log(response.acknowledgment);
} catch (error) {
    // Payment failed
    console.log(error);
}

```

Please note that the actual implementation would depend on the specific UPI app, the cryptocurrency exchange, and the payment gateway used. Also, this function's successful execution does not mean the payment has been completed, only that it has been initiated. The web app should listen for a notification at the provided callback URL to confirm when the payment has been processed.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ninjapay.gitbook.io/webupi-protocol/webupi-x-web3-bridge/get-started/webupi.sendpaymenttolightning.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
