stars#
This simple example handles stars payments.
from pyrogram import Client, filters, types
app = Client("bot_account")
@app.on_message(filters.command("support"))
async def message_handler(client: Client, message: types.Message):
await client.send_invoice(
message.chat.id,
title="Donate",
description="Support me",
currency="XTR",
prices=[types.LabeledPrice(label="Star", amount=1)],
payload="stars"
)
@app.on_pre_checkout_query()
async def pre_checkout_query_handler(_: Client, query: types.PreCheckoutQuery):
await query.answer(ok=True)
@app.on_message(filters.successful_payment)
async def successful_payment_handler(client: Client, message: types.Message):
await message.reply("Thanks for support! But I don't need stars for now! Take it back!")
await client.refund_star_payment(message.from_user.id, message.successful_payment.telegram_payment_charge_id)
app.run() # Automatically start() and idle()