From af49dacb095c3390c25f0ef6e0f91938fb90e395 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Wed, 12 Nov 2025 17:29:21 +0300 Subject: [PATCH] Features: 1) Handle `UnknownGatewayError` when processing transactions. Fixes: 1) Ensure `uuid` defaults to an empty string in `Transaction` retrieval. Extra: 1) Add missing import for `UnknownGatewayError`. --- engine/payments/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engine/payments/views.py b/engine/payments/views.py index 989c48c4..1c385582 100644 --- a/engine/payments/views.py +++ b/engine/payments/views.py @@ -9,6 +9,7 @@ from rest_framework.response import Response from rest_framework.views import APIView from engine.payments.docs.drf.views import DEPOSIT_SCHEMA +from engine.payments.gateways import UnknownGatewayError from engine.payments.models import Transaction from engine.payments.serializers import DepositSerializer, TransactionProcessSerializer @@ -71,7 +72,9 @@ class CallbackAPIView(APIView): def post(self, request: Request, *args: list[Any], **kwargs: dict[Any, Any]) -> Response: try: - transaction = Transaction.objects.get(uuid=kwargs.get("uuid")) + transaction = Transaction.objects.get(uuid=kwargs.get("uuid", "")) + if not transaction.gateway: + raise UnknownGatewayError() gateway = transaction.gateway.get_integration_class_object() gateway.process_callback(request.data) return Response(status=status.HTTP_202_ACCEPTED)