feat: changed TPV behaviour

This commit is contained in:
Pablo Moreno
2025-01-12 22:40:46 +01:00
parent fc0cdad246
commit a733325529
43 changed files with 1036 additions and 1100 deletions
+22
View File
@@ -0,0 +1,22 @@
from django.http.response import HttpResponse
from django.shortcuts import get_object_or_404
from django.views.decorators.csrf import csrf_exempt
from shop.models import Order
from shop.utils import validate_payment_for_order, pay_order
@csrf_exempt
def webhook(request, uuid):
order = get_object_or_404(Order, uuid=uuid)
try:
amount_paid = validate_payment_for_order(request, order)
pay_order(order, amount_paid)
return HttpResponse(status=200)
except Exception as e:
order.status = Order.Statuses.STATUS_ERROR
order.save()
return HttpResponse(status=409)