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");
}