admin管理员组

文章数量:1122846

I recently wrote a mini app in PHP for my Telegram bot. I intend to allow users to make purchases using Stars within the mini app, but I don't want the invoice to be sent within the bot. I want all processes, including sending, payment, and confirmation, to be handled within the mini app itself.

I couldn't find suitable documentation for this, and I saw a similar example in the Memefi Coin mini app earlier. If possible, could you guide me? Thank you!

I previously examined the sendInvoice method for sending invoices through the bot, and it seems that it doesn't have any functionality within the mini app. I tried to use the classes from the file telegram-web-app.js, such as WebApp.openInvoice, but I was unsuccessful, or I didn’t know how to use it and didn’t know where to obtain the input arguments for this function

For example, we have a button in the web app that, when clicked, will display a payment page with stars to the user:

<script src=".js"></script> <button type="button" onclick="clicked('price')">Pay</button>

Now, after clicking this button, a payment page should be shown to the user within the web app. As far as I understand, this can be done using WebApp.openInvoice, but I haven't been able to make it work. Where is my mistake?"

function clicked(price) {
    WebApp.openInvoice(";,".php");
}

I recently wrote a mini app in PHP for my Telegram bot. I intend to allow users to make purchases using Stars within the mini app, but I don't want the invoice to be sent within the bot. I want all processes, including sending, payment, and confirmation, to be handled within the mini app itself.

I couldn't find suitable documentation for this, and I saw a similar example in the Memefi Coin mini app earlier. If possible, could you guide me? Thank you!

I previously examined the sendInvoice method for sending invoices through the bot, and it seems that it doesn't have any functionality within the mini app. I tried to use the classes from the file telegram-web-app.js, such as WebApp.openInvoice, but I was unsuccessful, or I didn’t know how to use it and didn’t know where to obtain the input arguments for this function

For example, we have a button in the web app that, when clicked, will display a payment page with stars to the user:

<script src="https://telegram.org/js/telegram-web-app.js"></script> <button type="button" onclick="clicked('price')">Pay</button>

Now, after clicking this button, a payment page should be shown to the user within the web app. As far as I understand, this can be done using WebApp.openInvoice, but I haven't been able to make it work. Where is my mistake?"

function clicked(price) {
    WebApp.openInvoice("https://t.me/mybotusername","https://example.com/mybot.php");
}
Share Improve this question asked Nov 22, 2024 at 10:38 PantherousPantherous 11
Add a comment  | 

1 Answer 1

Reset to default 0

The problem was that I did not use openInvoice correctly.

The way to call openInvoice using JavaScript is as follows:

window.Telegram.WebApp.openInvoice("linkOfInvoice","CallBack(optional)")

To obtain "linkOfInvoice", we can use the Telegram API and the createInvoiceLink method.

本文标签: phpSend Invoice In Telegram MiniAppStack Overflow