Search code examples
pythontelegrampayment

how to send send_invoice method using telebot?


So, I am doing the bot on telegram, and I want it to send invoices. this is the code I try to send invoices with:

bot.send_invoice(chat_id=chat_id, title="Flowers Delivery", description=description_of_package,
                 invoice_payload='some-invoice-payload-for-internal-use',
                 provider_token=keys.TEST_TRANZZO_PAYMENT, currency="UAH",
                 prices=[{'label': 'flowers', 'amount': 1000}], start_parameter="test-start-parameter")

And this is the mistake I get:

2021-05-26 10:50:27,091 (__init__.py:544 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: there must be at least one price"

Solution

  • If you are using the telebot library, this example page shows that you need to import LabeledPrice

    from telebot.types import LabeledPrice
    
    prices = [LabeledPrice(label='Working Time Machine', amount=5750),
        LabeledPrice('Gift wrapping', 500)]