from rest_framework.permissions import AllowAny from rest_framework.response import Response from rest_framework.views import APIView from .serializers import PaymentWebhookSerializer from .services import handle_yookassa_webhook class YooKassaWebhookView(APIView): """Receives ЮKassa notifications. TODO: verify the source IP / signature before applying the event. """ permission_classes = [AllowAny] authentication_classes: list = [] serializer_class = PaymentWebhookSerializer def post(self, request): payment = handle_yookassa_webhook(request.data) if payment is None: return Response({"detail": "ignored"}) return Response({"detail": "ok"})