Skip to content
Back to top
View this page

# TransactionPartnerUser

class telegram.TransactionPartnerUser(transaction_type, user, invoice_payload=None, paid_media=None, paid_media_payload=None, subscription_period=None, gift=None, affiliate=None, premium_subscription_duration=None, *, api_kwargs=None)

  Bases: `telegram.TransactionPartner`

  Describes a transaction with a user.

  Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their `user` and `transaction_type` are equal.

  Available In

  - `telegram.StarTransaction.receiver`

  - `telegram.StarTransaction.source`

  Added in version 21.4.

  Changed in version 22.1: Equality comparison now includes the new required argument `transaction_type`, introduced in Bot API 9.0.

  Parameters:

    - transaction_type (`str`) –

      Type of the transaction, currently one of `'invoice_payment'` for payments via invoices, `'paid_media_payment'` for payments for paid media, `'gift_purchase'` for gifts sent by the bot, `'premium_purchase'` for Telegram Premium subscriptions gifted by the bot, `'business_account_transfer'` for direct transfers from managed business accounts.

      Added in version 22.1.

    - user (`telegram.User`) – Information about the user.

    - affiliate (`telegram.AffiliateInfo`, optional) –

      Information about the affiliate that received a commission via this transaction. Can be available only for `'invoice_payment'` and `'paid_media_payment'` transactions.

      Added in version 21.9.

    - invoice_payload (`str`, optional) – Bot-specified invoice payload. Can be available only for `'invoice_payment'` transactions.

    - subscription_period (`int` | `datetime.timedelta`, optional) –

      The duration of the paid subscription. Can be available only for `'invoice_payment'` transactions.

      Added in version 21.8.

      Changed in version v22.2: Accepts `int` objects as well as `datetime.timedelta`.

    - paid_media (Sequence[`telegram.PaidMedia`], optional) –

      Information about the paid media bought by the user. for `'paid_media_payment'` transactions only.

      Added in version 21.5.

    - paid_media_payload (`str`, optional) –

      Bot-specified paid media payload. Can be available only for `'paid_media_payment'` transactions.

      Added in version 21.6.

    - gift (`telegram.Gift`, optional) –

      The gift sent to the user by the bot; for `'gift_purchase'` transactions only.

      Added in version 21.8.

    - premium_subscription_duration (`int`, optional) –

      Number of months the gifted Telegram Premium subscription will be active for; for `'premium_purchase'` transactions only.

      Added in version 22.1.

  type

    The type of the transaction partner, always `'user'`.

    Type:

      `str`

  transaction_type

    Type of the transaction, currently one of `'invoice_payment'` for payments via invoices, `'paid_media_payment'` for payments for paid media, `'gift_purchase'` for gifts sent by the bot, `'premium_purchase'` for Telegram Premium subscriptions gifted by the bot, `'business_account_transfer'` for direct transfers from managed business accounts.

    Added in version 22.1.

    Type:

      `str`

  user

    Information about the user.

    Type:

      `telegram.User`

  affiliate

    Optional. Information about the affiliate that received a commission via this transaction. Can be available only for `'invoice_payment'` and `'paid_media_payment'` transactions.

    Added in version 21.9.

    Type:

      `telegram.AffiliateInfo`

  invoice_payload

    Optional. Bot-specified invoice payload. Can be available only for `'invoice_payment'` transactions.

    Type:

      `str`

  subscription_period

    Optional. The duration of the paid subscription. Can be available only for `'invoice_payment'` transactions.

    Added in version 21.8.

    Type:

      `datetime.timedelta`

  paid_media

    Optional. Information about the paid media bought by the user. for `'paid_media_payment'` transactions only.

    Added in version 21.5.

    Type:

      tuple[`telegram.PaidMedia`]

  paid_media_payload

    Optional. Bot-specified paid media payload. Can be available only for `'paid_media_payment'` transactions.

    Added in version 21.6.

    Type:

      `str`

  gift

    Optional. The gift sent to the user by the bot; for `'gift_purchase'` transactions only.

    Added in version 21.8.

    Type:

      `telegram.Gift`

  premium_subscription_duration

    Optional. Number of months the gifted Telegram Premium subscription will be active for; for `'premium_purchase'` transactions only.

    Added in version 22.1.

    Type:

      `int`

  classmethod de_json(data, bot=None)

    See `telegram.TransactionPartner.de_json()`.