charge to payment intent
This commit is contained in:
@@ -215,7 +215,7 @@ class PaymentProcessingService:
|
||||
return Subscription.objects.get(id=subscription)
|
||||
|
||||
def process_event(self):
|
||||
if self.event_type == "charge.succeeded":
|
||||
if self.event_type == "payment_intent.succeeded":
|
||||
self._handle_success()
|
||||
else:
|
||||
self._handle_failure()
|
||||
|
||||
@@ -116,50 +116,6 @@ class CreatePrincipalSubscriptionApi(APIView):
|
||||
return ApiResponse.error(**fail_response)
|
||||
|
||||
|
||||
# class CreatePrincipalSubscriptionApi(APIView):
|
||||
# authentication_classes = [JWTAuthentication]
|
||||
# permission_classes = [IsAuthenticated]
|
||||
|
||||
# def post(self, request):
|
||||
# serializer = PrincipalSubscriptionSerializer(data=request.data)
|
||||
|
||||
# if serializer.is_valid():
|
||||
# subscription_id = serializer.validated_data.get("subscription").id
|
||||
# try:
|
||||
# subscription = Subscription.objects.get(id=subscription_id)
|
||||
# except Subscription.DoesNotExist:
|
||||
# return ApiResponse.error(
|
||||
# status=status.HTTP_404_NOT_FOUND, message="Subscription not found."
|
||||
# )
|
||||
|
||||
# start_date = timezone.localtime().date()
|
||||
# end_date = start_date + timedelta(days=subscription.plan.days)
|
||||
# grace_period_end_date = end_date + timedelta(days=15)
|
||||
|
||||
# # You can directly pass the additional fields as save method arguments
|
||||
# instance = serializer.save(
|
||||
# start_date=start_date,
|
||||
# end_date=end_date,
|
||||
# grace_period_end_date=grace_period_end_date,
|
||||
# created_by=request.user, # Assuming your model has this field and you want to track who created the subscription
|
||||
# )
|
||||
|
||||
# success_response = {
|
||||
# "status": status.HTTP_201_CREATED, # Use 201 for successful resource creation
|
||||
# "message": "Success",
|
||||
# "data": serializer.data,
|
||||
# }
|
||||
# return ApiResponse.success(**success_response)
|
||||
|
||||
# else:
|
||||
# fail_response = {
|
||||
# "status": status.HTTP_400_BAD_REQUEST,
|
||||
# "message": "Validation Failed",
|
||||
# "errors": serializer.errors,
|
||||
# }
|
||||
# return ApiResponse.error(**fail_response)
|
||||
|
||||
|
||||
@method_decorator(csrf_exempt, name="dispatch")
|
||||
class StripeWebhookTest(APIView):
|
||||
authentication_classes = []
|
||||
|
||||
Reference in New Issue
Block a user