@tasto

Почему после оплаты выдает bot pre checkout timeout?

import asyncio
import types

from aiogram import Bot, Dispatcher, F
from aiogram.filters import Command, CommandStart
from aiogram.types import Message, LabeledPrice, PreCheckoutQuery, CallbackQuery, ContentType



import os
import logging

import keyboards

#token
bot = Bot('')
dp = Dispatcher()


@dp.message(Command("start"))
async def start(message: Message):
    await message.answer('Привет.', reply_markup=keyboards.main_kb)


@dp.message(F.text.lower().in_(['оплатить']))
async def order(call: CallbackQuery):
    await call.bot.send_invoice(
            chat_id= call.from_user.id,
            title="Покупка курса",
            description='Оплата',
            payload='Payment',
            provider_token='',
            currency='rub',
            prices=[LabeledPrice(label='Покупка курса', amount=39900)],
            start_parameter='KSQ_bot',
            provider_data=None,
            need_name=False,
            need_email=False,
            need_shipping_address=False,
            is_flexible=False,
            disable_notification=True,
            protect_content=False,
            allow_sending_without_reply=True,
            reply_markup=None,
            request_timeout=70
    )

async def process_pre_checkout_query(pre_checkout_query: PreCheckoutQuery, bot: Bot):
    await bot.answer_pre_checkout_query(pre_checkout_query.id, ok=True)
    print(pre_checkout_query)

async def successful_payment(message: Message):
    msg = f'Спасибо за оплату {message.successful_payment.total_amount // 100} {message.successful_payment.currency}.'\
          f'\r\nваш документ -'
    await message.answer(msg)


@dp.message()
async def echo(message: Message):
    msg = message.text.lower()

    if msg == 'помощь':
        await message.answer('Моя контактная информация:', reply_markup=keyboards.links_kb)
    elif msg == 'хочу купить сборник':
        await message.answer("сборник",
                             reply_markup=keyboards.pof_kb)


async def main():
    await bot.delete_webhook(drop_pending_updates=True)
    await dp.start_polling(bot)


if __name__ == "__main__":
    asyncio.run(main())

from aiogram.types import (
    ReplyKeyboardMarkup,
    KeyboardButton,
    InlineKeyboardMarkup,
    InlineKeyboardButton
)

main_kb = ReplyKeyboardMarkup(
    keyboard=[
        [
            KeyboardButton(text='Хочу купить сборник'),
            KeyboardButton(text='Помощь')
        ]
    ],
    resize_keyboard=True,
    one_time_keyboard=True,
    input_field_placeholder='Выберите действие из меню'
)

links_kb = InlineKeyboardMarkup(
    inline_keyboard=[
        [
            InlineKeyboardButton(text="VK", url=""),
            InlineKeyboardButton(text="Telegram", url=""),
            InlineKeyboardButton(text="Instagram", url="")
        ]
    ]
)


pof_kb = ReplyKeyboardMarkup(
    keyboard=[
        [
            KeyboardButton(text='Оплатить')
        ]
    ],
    resize_keyboard=True,
    one_time_keyboard=True,
    input_field_placeholder='Выберите действие из меню'
)

как исправить?
  • Вопрос задан
  • 367 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы