diff --git a/engine/payments/urls.py b/engine/payments/urls.py index 02abddf3..b3837941 100644 --- a/engine/payments/urls.py +++ b/engine/payments/urls.py @@ -12,5 +12,5 @@ payment_router.register(prefix=r"transactions", viewset=TransactionViewSet, base urlpatterns = [ path(r"", include(payment_router.urls)), path(r"deposit/", DepositView.as_view()), - path(r"/callback//", CallbackAPIView.as_view()), + path(r"/callback/", CallbackAPIView.as_view()), ] diff --git a/engine/payments/views.py b/engine/payments/views.py index dde5012c..989c48c4 100644 --- a/engine/payments/views.py +++ b/engine/payments/views.py @@ -9,7 +9,6 @@ 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 @@ -72,14 +71,10 @@ class CallbackAPIView(APIView): def post(self, request: Request, *args: list[Any], **kwargs: dict[Any, Any]) -> Response: try: - gateway = kwargs.get("gateway", "") - # noinspection PyUnreachableCode - match gateway: - case "gateway": - # Gateway.process_callback(request.data) - return Response(status=status.HTTP_200_OK) - case _: - raise UnknownGatewayError(f"Couldn't match '{gateway}' any gateway") + transaction = Transaction.objects.get(uuid=kwargs.get("uuid")) + gateway = transaction.gateway.get_integration_class_object() + gateway.process_callback(request.data) + return Response(status=status.HTTP_202_ACCEPTED) except Exception as e: return Response( status=status.HTTP_500_INTERNAL_SERVER_ERROR, data={"error": f"{e}; {traceback.format_exc()}"}