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
1 Answer
Reset to default 0The 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
版权声明:本文标题:php - Send Invoice In Telegram MiniApp - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736304462a1932242.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论