@unoiii1

Как можно выставить счёт на 15 минут?

Бот выставляет счёт на 5 часов, на 15 и т.д, но на 15 минут или меньше почему то не хочет и выдаёт ошибку:

ERROR:asyncio:Task exception was never retrieved future: exception=QiwiError("validation.error - Validation error, please modify your request according to API specification; Cause: unknown. {'expirationDateTime': ['must be a future date']}")> Traceback (most recent call last): File "C:\Users\Developer\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 415, in _process_polling_updates for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)): File "C:\Users\Developer\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 235, in process_updates return await asyncio.gather(*tasks) File "C:\Users\Developer\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\handler.py", line 116, in notify response = await handler_obj.handler(*args, **partial_data) File "C:\Users\Developer\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 256, in process_update return await self.message_handlers.notify(update.message) File "C:\Users\Developer\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\handler.py", line 116, in notify response = await handler_obj.handler(*args, **partial_data) File "C:\Users\Developer\Desktop\bot\main.py", line 108, in buy bill = p2p.bill(bill_id=random_id, amount=price, lifetime=lifetime, comment=comment) File "C:\Users\Developer\AppData\Local\Programs\Python\Python310\lib\site-packages\pyqiwip2p\Qiwip2p.py", line 95, in bill qiwi_response = Bill(qiwi_raw_response, self) File "C:\Users\Developer\AppData\Local\Programs\Python\Python310\lib\site-packages\pyqiwip2p\p2p_types\Responses.py", line 67, in init raise QiwiError(self.r_json) pyqiwip2p.p2p_types.Errors.QiwiError: validation.error - Validation error, please modify your request according to API specification; Cause: unknown


Код:
@dp.message_handler(commands=['pay_qiwi_1'])
async def buy(message: types.Message):
    global bill
    price = 150 
    lifetime = 100
    random_id = random.random()
    comment = f'ID: {message.from_user.id}, NAME: {message.from_user.first_name} {message.from_user.last_name}, USERNAME: {message.from_user.username}'
    bill = p2p.bill(bill_id=random_id, amount=price, lifetime=lifetime, comment=comment)
    await bot.send_message(message.from_user.id, f'<a href="{bill.pay_url}">Ссылка на оплату Qiwi {price} р.</a>')
    x = threading.Thread(target=functionoplata, args=(message,))
    x.start()
def functionoplata(message):
    oplata_time = datetime.datetime.now()
    datetime_delta = oplata_time + timedelta(minutes=15) 
    while True:
        status = p2p.check(bill_id=bill.bill_id).status 
        if status == 'PAID':
            chat_id = message.from_user.id
            balance = int(1)
            db.addBalance(message.from_user.id, balance)
            pay_result = "На ваш счет зачислен 1 запрос"
            requests.post(f"https://api.telegram.org/bot2140672186:AAGWMIR00YzbtVcDv_TkLQscxary_Gtq79U/sendMessage?chat_id={chat_id}&text={pay_result}").json()
            break
        elif datetime.datetime.now() > datetime_delta:
            chat_id = message.from_user.id
            pay_result = "Срок действия ссылки закончился!"
            requests.post(f"https://api.telegram.org/bot2140672186:AAGWMIR00YzbtVcDv_TkLQscxary_Gtq79U/sendMessage?chat_id={chat_id}&text={pay_result}").json()
            break 
    time.sleep(0.1)


Библиотека:
pyqiwip2p
  • Вопрос задан
  • 232 просмотра
Решения вопроса 1
Validation error, please modify your request according to API specification; Cause: unknown. {'expirationDateTime': ['must be a future date']}

Вроде, довольно понятно всё написано.
Только вот ничто в вопросе нам не даёт информацию о том, откуда эта ошибка берётся. Я так полагаю, что из p2p.bill() - проверяйте, что за аргументы вы туда передаёте.

Комбинация "работает при условии нескольких часов" и "дата в прошлом" намекают на проблемы с таймзоной.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

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

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