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`.
This commit is contained in:
parent
b03757508b
commit
af49dacb09
1 changed files with 4 additions and 1 deletions
|
|
@ -9,6 +9,7 @@ from rest_framework.response import Response
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
|
||||||
from engine.payments.docs.drf.views import DEPOSIT_SCHEMA
|
from engine.payments.docs.drf.views import DEPOSIT_SCHEMA
|
||||||
|
from engine.payments.gateways import UnknownGatewayError
|
||||||
from engine.payments.models import Transaction
|
from engine.payments.models import Transaction
|
||||||
from engine.payments.serializers import DepositSerializer, TransactionProcessSerializer
|
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:
|
def post(self, request: Request, *args: list[Any], **kwargs: dict[Any, Any]) -> Response:
|
||||||
try:
|
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 = transaction.gateway.get_integration_class_object()
|
||||||
gateway.process_callback(request.data)
|
gateway.process_callback(request.data)
|
||||||
return Response(status=status.HTTP_202_ACCEPTED)
|
return Response(status=status.HTTP_202_ACCEPTED)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue