Django raise BadRequestError(msg) razorpay.errors.BadRequestError: Сумма должна быть целым числом. while refund

Когда я пытаюсь распечатать его, он отображается как целое число, но я получаю ошибку "The amount must be an integer.", когда я запускаю проект

enter image description here

if str(Payments).__contains__("pay"):
    paymentId = Payments.payment_id
    amount = int(Payments.amount_paid)
    refund_amount = int(amount) * 100
    reamount = int(refund_amount)
    print(reamount)
    print(type(reamount))

    client = razorpay.Client(auth=(settings.RAZOR_KEY_ID, settings.RAZOR_KEY_SECRET))

    client.payment.refund(
        paymentId,
        {
            "amount": reamount,
            "speed": "optimum",
        },
    )

    # addning stock in product
    order_items = OrderProduct.objects.filter(order=order)
    for item in order_items:
        product = Product.objects.get(id=item.product_id)
        product.stock += item.quantity
        product.save()

enter image description here

Я только что изменил тип dict на прямую передачу параметров

#refund process of stripe
if str(Payments).__contains__("pay"):
    paymentId     = Payments.payment_id
    refund_amount = Payments.amount_paid
    amount        = int(refund_amount * 100)

    
    client = razorpay.Client(auth=(settings.RAZOR_KEY_ID, settings.RAZOR_KEY_SECRET))
    print(paymentId)
    client.payment.refund( paymentId,amount,)

    #addning stock in product
    order_items = OrderProduct.objects.filter(order=order)
    for item in order_items:
        product = Product.objects.get(id=item.product_id)
        product.stock += item.quantity
        product.save()

Тогда он работает

enter image description here

enter image description here

Вернуться на верх