Add payment in django project to extend an expiration date of posts./

I have a project where the user can post an Ad and this Ad will be available only for 30 days.

I need to add a payment method to extend the Expiration date of the Ad.

Here is my Ad creation view .

class AdvertiseCreateView(APIView):
permission_classes = [IsAuthenticated]
def post(self, request):
    serializer = AdvertiseSerializer(
    user = request.user
    if serializer.is_valid():
        print(user) = user)
        return Response(, status=status.HTTP_201_CREATED)
    return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

List view:

class AdvertisesListView(APIView):
def get(self, request):
    advertises = Advertise.objects.filter(Q (expiration_date__gt = Now()))
    serializer = AdvertiseSerializer(advertises, many=True)
    return Response(, status = status.HTTP_200_OK)


class Advertise(models.Model):
owner = models.ForeignKey(User, on_delete=models.CASCADE, related_name="advertise")
category = models.CharField(max_length= 200, choices = CATEGORY)
location = models.CharField(max_length= 200, choices = LOCATIONS)
description = models.TextField(max_length=600)
price = models.FloatField(max_length=100)
expiration_date  = models.DateField(default = Expire_date, blank=True, null=True) #Expire date come from another file
created_at = models.DateTimeField(auto_now_add=True, blank=True, null=True)
updated_at = models.DateTimeField(auto_now=True, blank=True, null=True)

class Meta:
    ordering = ['created_at']

def __str__(self):
    return self.category

So the thing is when the user make his payment the expire date extends.

I need help in payment part.

Thanks in Advance.

Back to Top