Skip to content
Back to top
View this page

# PreCheckoutQueryHandler

class telegram.ext.PreCheckoutQueryHandler(callback, block=True, pattern=None)

  Bases: `telegram.ext.BaseHandler`

  Handler class to handle Telegram `telegram.Update.pre_checkout_query`.

  Warning

  When setting `block` to `False`, you cannot rely on adding custom attributes to `telegram.ext.CallbackContext`. See its docs for more info.

  Examples

  Payment Bot

  Use In

  - `telegram.ext.Application.add_handler()`

  - `telegram.ext.Application.add_handlers()`

  - `telegram.ext.Application.remove_handler()`

  Available In

  - `telegram.ext.ConversationHandler.entry_points`

  - `telegram.ext.ConversationHandler.fallbacks`

  - `telegram.ext.ConversationHandler.states`

  Parameters:

    - callback (coroutine function) –

      The callback function for this handler. Will be called when `check_update()` has determined that an update should be processed by this handler. Callback signature:

          async def callback(update: Update, context: CallbackContext)

      The return value of the callback is usually ignored except for the special case of `telegram.ext.ConversationHandler`.

    - block (`bool`, optional) –

      Determines whether the return value of the callback should be awaited before processing the next handler in `telegram.ext.Application.process_update()`. Defaults to `True`.

      See also

      Concurrency

    - pattern (`str` | `re.Pattern`, optional) –

      Optional. Regex pattern to test `telegram.PreCheckoutQuery.invoice_payload` against.

      Added in version 20.8.

  callback

    The callback function for this handler.

    Type:

      coroutine function

  block

    Determines whether the callback will run in a blocking way..

    Type:

      `bool`

  pattern

    Optional. Regex pattern to test `telegram.PreCheckoutQuery.invoice_payload` against.

    Added in version 20.8.

    Type:

      `str` | `re.Pattern`, optional

  check_update(update)

    Determines whether an update should be passed to this handler’s `callback`.

    Parameters:

      update (`telegram.Update` | `object`) – Incoming update.

    Returns:

      `bool`