aiogram/aiogram/methods/send_invoice.py
2021-01-24 01:31:05 +02:00

73 lines
3.8 KiB
Python

from __future__ import annotations
from typing import TYPE_CHECKING, Any, Dict, List, Optional
from ..types import InlineKeyboardMarkup, LabeledPrice, Message
from .base import Request, TelegramMethod
if TYPE_CHECKING: # pragma: no cover
from ..client.bot import Bot
class SendInvoice(TelegramMethod[Message]):
"""
Use this method to send invoices. On success, the sent `Message <https://core.telegram.org/bots/api#message>`_ is returned.
Source: https://core.telegram.org/bots/api#sendinvoice
"""
__returning__ = Message
chat_id: int
"""Unique identifier for the target private chat"""
title: str
"""Product name, 1-32 characters"""
description: str
"""Product description, 1-255 characters"""
payload: str
"""Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes."""
provider_token: str
"""Payments provider token, obtained via `Botfather <https://t.me/botfather>`_"""
start_parameter: str
"""Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter"""
currency: str
"""Three-letter ISO 4217 currency code, see `more on currencies <https://core.telegram.org/bots/payments#supported-currencies>`_"""
prices: List[LabeledPrice]
"""Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)"""
provider_data: Optional[str] = None
"""A JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider."""
photo_url: Optional[str] = None
"""URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for."""
photo_size: Optional[int] = None
"""Photo size"""
photo_width: Optional[int] = None
"""Photo width"""
photo_height: Optional[int] = None
"""Photo height"""
need_name: Optional[bool] = None
"""Pass *True*, if you require the user's full name to complete the order"""
need_phone_number: Optional[bool] = None
"""Pass *True*, if you require the user's phone number to complete the order"""
need_email: Optional[bool] = None
"""Pass *True*, if you require the user's email address to complete the order"""
need_shipping_address: Optional[bool] = None
"""Pass *True*, if you require the user's shipping address to complete the order"""
send_phone_number_to_provider: Optional[bool] = None
"""Pass *True*, if user's phone number should be sent to provider"""
send_email_to_provider: Optional[bool] = None
"""Pass *True*, if user's email address should be sent to provider"""
is_flexible: Optional[bool] = None
"""Pass *True*, if the final price depends on the shipping method"""
disable_notification: Optional[bool] = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message"""
allow_sending_without_reply: Optional[bool] = None
"""Pass *True*, if the message should be sent even if the specified replied-to message is not found"""
reply_markup: Optional[InlineKeyboardMarkup] = None
"""A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_. If empty, one 'Pay :code:`total price`' button will be shown. If not empty, the first button must be a Pay button."""
def build_request(self, bot: Bot) -> Request:
data: Dict[str, Any] = self.dict()
return Request(method="sendInvoice", data=data)