Skip to content

Payment is not working if written AFTER a conversation handler #927

@CeuxDruman

Description

@CeuxDruman

Steps to reproduce

  1. Just make a test payment as shown in the official example https://github.com/python-telegram-bot/python-telegram-bot/blob/master/examples/paymentbot.py

  2. Add the payment handlers AFTER a conversation handler, like this:

conv_handler = ConversationHandler(
    ...
)

# Add command handler to start the payment invoice
dp.add_handler(CommandHandler("shipping", start_with_shipping_callback))
dp.add_handler(CommandHandler("noshipping", start_without_shipping_callback))

# Optional handler if your product requires shipping
dp.add_handler(ShippingQueryHandler(shipping_callback))

# Pre-checkout handler to final check
dp.add_handler(PreCheckoutQueryHandler(precheckout_callback))

# Success! Notify your user!
dp.add_handler(MessageHandler(Filters.successful_payment, successful_payment_callback))
  1. Run it and try to make a payment (I used /noshipping).

Expected behaviour

It should let you make the full payment successfully.

Actual behaviour

It lets you type all payment information, but in the last step, when clicking the last "Pay" button, it crash (see Logs) and doesn't call precheckout_callback function throw PreCheckoutQueryHandler.

Additional information

  • It works perfectly if you add it BEFORE the ConversationHandler.
  • It seems to be recognized as if payment handlers were located inside the ConversationHandler.
  • I don't think it to affect this issue, but I'm using Stripe payment in testing mode.

Configuration

I'm using the last version up to date. (e8fac19)

Logs

2017-12-02 17:31:52,827 - telegram.ext.dispatcher - ERROR - An uncaught error was raised while processing the update
Traceback (most recent call last):
  File "C:\Users\Carlos\Documents\Programacion\TelegramBots\Pickatext\telegram\ext\dispatcher.py", line 278, in process_update
    for handler in (x for x in self.handlers[group] if x.check_update(update)):
  File "C:\Users\Carlos\Documents\Programacion\TelegramBots\Pickatext\telegram\ext\dispatcher.py", line 278, in <genexpr>
    for handler in (x for x in self.handlers[group] if x.check_update(update)):
  File "C:\Users\Carlos\Documents\Programacion\TelegramBots\Pickatext\telegram\ext\conversationhandler.py", line 215, in check_update
    key = self._get_key(update)
  File "C:\Users\Carlos\Documents\Programacion\TelegramBots\Pickatext\telegram\ext\conversationhandler.py", line 185, in _get_key
    key.append(chat.id)
AttributeError: 'NoneType' object has no attribute 'id'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy