With the 26th April update on Telegram introducing the Payments 2.0 feature along with other minor features, I’ve decided to build a Telegram bot that included these features. However, since this is a recent update with limited example documentation (and the syntax can take a while to digest), I was stuck implementing the Payment 2.0 feature and wanted to ask anyone who has done this (or is experienced in this verse) on a few matters:
- In answering shipping / pre-checkout queries (answerShippingQuery,
answerPreCheckoutQuery), I understand that the API will send an
Update with the field to the bot for it to respond properly. However,
I am not too sure how to approach this after creating the invoice
given the parameters and arguments and would love to understand some
form of a “code snippet” to understand how the processes work (or do
I have to use an asynchronous function?).
def command TelegramShop(update: Update, _: CallbackContext): user = update.message.from_user Product = telegram.LabeledPrice("Demostration Product", 1000) ShippingMethod_1 = telegram.LabeledPrice("Self Collection", 0) ShippingMethod_2 = telegram.LabeledPrice("Mail In Delivery", 100) ShippingMethod_3= telegram.LabeledPrice("Tracked Mail In Delivery", 250) print("Hello") _.bot.sendInvoice(chat_id = user.id, title = "Demostration Product", description = "This box demostration does wonders!", payload = "productpayload", provider_token = "TOKEN", currency = "USD", prices = [Product], need_phone_number = True, need_email = True, need_shipping_address = True, send_phone_number_to_provider = True, send_email_to_provider = True, is_flexible = True) # Unsure how to add this answering of shipping query into the Telegram Bot. _.bot.answerShippingQuery(shipping_query_id = "swiftboxA", ok = False, error_message = "sorry, this does not work!")
- There are numerous identifiers within Payment API 2.0 ranging from
shipping_query_id
,pre_checkout_query_id
and even payment identifiers such astelegram_payment_charge_id
andprovider_payment_charge_id
. How do I go about obtaining these identifiers and for the payment identifiers, is there an appropriate code snippet illustrating their use?