From ca08d0aeb0cd6ad3935d6e5098a0d971f0575ec1 Mon Sep 17 00:00:00 2001 From: rizwanisready Date: Fri, 24 May 2024 21:16:30 +0530 Subject: [PATCH] existing subscription validation 7 --- manage_subscriptions/views.py | 10 +++++----- templates/stripe_html/index.html | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/manage_subscriptions/views.py b/manage_subscriptions/views.py index 383e465..b943887 100644 --- a/manage_subscriptions/views.py +++ b/manage_subscriptions/views.py @@ -353,7 +353,7 @@ class SubscriptionPageView(TemplateView): token = request.GET.get("token") or request.session.get("jwt") print("token: ", token) if token: - request.session['jwt'] = token + request.session["jwt"] = token print("request.session: ", request.session) try: # Decode and validate token @@ -429,14 +429,14 @@ def create_checkout_session(request): if has_active_principal_subscription(principal_id): print("Active principal subscription already exists.") - return JsonResponse({"error-message": "Active principal subscription already exists"}, status=400) + return JsonResponse( + {"error": "Active principal subscription already exists"}, status=400 + ) try: subscription = Subscription.objects.get(id=subscription_id) except Subscription.DoesNotExist: - return ApiResponse.error( - status=status.HTTP_404_NOT_FOUND, message="Subscription not found." - ) + return JsonResponse({"error": "Subscription not found."}, status=404) order_id = ( "order_" + str(timezone.localtime().timestamp()) + str(request.user.email) diff --git a/templates/stripe_html/index.html b/templates/stripe_html/index.html index 1914b80..75ff006 100644 --- a/templates/stripe_html/index.html +++ b/templates/stripe_html/index.html @@ -548,6 +548,7 @@ }) .catch((error) => { console.error("Error:", error); + document.getElementById('error-message').innerText = "Error: " + error.message; button.disabled = false; }); });