U
U
unoiii12021-12-17 13:23:17
Python
unoiii1, 2021-12-17 13:23:17

How can I bill for 15 minutes?

The bot bills for 5 hours, 15, etc., but for some reason does not want to 15 minutes or less and gives an error:

please modify your request according to API specification; Cause: unknown please modify your request according to API specification; Cause: unknown


The code:
@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)


Library:
pyqiwip2p

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2021-12-17
@unoiii1

Validation error, please modify your request according to API specification; Cause: unknown. {'expirationDateTime': ['must be a future date']}

It seems to be written quite clearly.
Only nothing in the question gives us information about where this error comes from. I believe that from p2p.bill() - check what arguments you are passing there.
The combination "works on the condition of several hours" and "date in the past" hint at problems with the timezone.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question