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:
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!")
shipping_query_id, pre_checkout_query_id and even payment identifiers
such as telegram_payment_charge_id and provider_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?TBH I haven't worked with payments much so far, but regarding "limited expample documentation" I would like to point you to
python-telegram-botIf you have already seen these (which wasn't clear to my from your question), please just ignore my answer.
Also a side note: You should rename the second parameter from _ to context. The underscore is just a convention for unused parameters, but you apparently want to use it ;)
Disclaimer: I'm currently the maitainer of python-telegram-bot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With