Skip to content

Commit

Permalink
feat: delete payment api endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Shavkatjon-O committed Sep 12, 2024
1 parent 8097e81 commit cf6fd3f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/payments/api/PaymentDelete/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .views import *
23 changes: 23 additions & 0 deletions apps/payments/api/PaymentDelete/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from rest_framework import serializers
from apps.payments.models import Payment


class PaymentDeleteSerializer(serializers.ModelSerializer):
class Meta:
model = Payment
fields = (
"id",
"amount",
"currency",
"payment_type",
"payment_method",
"date",
"description",
"created_by",
"approved_by",
"reference_number",
"status",
)


__all__ = ("PaymentDeleteSerializer",)
14 changes: 14 additions & 0 deletions apps/payments/api/PaymentDelete/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from rest_framework.generics import DestroyAPIView
from rest_framework.permissions import IsAuthenticated

from apps.payments.api.PaymentDelete.serializers import PaymentDeleteSerializer
from apps.payments.models import Payment


class PaymentDeleteAPIView(DestroyAPIView):
serializer_class = PaymentDeleteSerializer
permission_classes = (IsAuthenticated,)
queryset = Payment.objects.all()


__all__ = ("PaymentDeleteAPIView",)
1 change: 1 addition & 0 deletions apps/payments/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .PaymentCreate import *
from .PaymentDelete import *
2 changes: 2 additions & 0 deletions apps/payments/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from django.urls import path

from apps.payments.api.PaymentCreate.views import PaymentCreateAPIView
from apps.payments.api.PaymentDelete.views import PaymentDeleteAPIView

urlpatterns = [
path("create/", PaymentCreateAPIView.as_view(), name="payment-create"),
path("delete/<int:pk>/", PaymentDeleteAPIView.as_view(), name="payment-delete"),
]

0 comments on commit cf6fd3f

Please sign in to comment.