KurimuzonAkuma / pyrogram

Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots
https://pyrogram.org
GNU Lesser General Public License v3.0
267 stars 72 forks source link

Add high level support for pre-checkout queries and service messages for successful payments #67

Closed coglione closed 1 month ago

coglione commented 1 month ago

Given the upcoming Telegram update that will introduce Telegram Stars, here's a pull requests that adds support for pre-checkout queries by adding PreCheckoutQuery:

@app.on_pre_checkout_query()
async def pre_checkout(client, pre_checkout_query):
    # do something with the query
    await pre_checkout_query.answer(success=True)

and support for service messages for successful payments by adding SuccessfulPayment and the corresponding filter:

@app.on_message(filters.successful_payment)
async def payment(client, message):
    payment = message.successful_payment
    amount, currency = payment.total_amount, payment.currency
    # do something