This commit is contained in:
Martin Quarda 2024-10-14 10:22:09 +02:00
parent 8b29bbab64
commit d024860a59

View File

@ -394,8 +394,10 @@ def cart_buy(request):
invoice = Invoice(
user=user,
address=user.profile.address,
invoice_id=Invoice.next_invoice_id()
invoice_id=Invoice.next_invoice_id(),
total_price=0,
)
total_price = 0
invoice.save()
for cp in cart_products:
@ -407,12 +409,13 @@ def cart_buy(request):
)
cp.product.quantity -= cp.quantity
cp.product.save()
total_price += cp.quantity * cp.product.price
ip.save()
payment_data = {
'merchant': COMGATE_MERCHANT,
'test': 'true' if COMGATE_TEST else 'false',
'price': invoice.calculate_total_price() * 100,
'price': total_price * 100,
'curr': 'CZK',
'method': 'ALL',
'label': 'Merch Alkátor Race',
@ -432,6 +435,7 @@ def cart_buy(request):
invoice.delete()
return HttpResponse('{"reason":"Chyba na straně platební brány: ' + result['message'][0] + ', zkuste prosím nákup později."}', status=400, content_type='application/json')
invoice.total_price = total_price
invoice.trans_id = result['transId'][0]
cart.delete()
invoice.save()