From ceff7964e915d7c9e6264e7364b5bf3d8696d16a Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 18 Jul 2019 10:13:03 +0530 Subject: [PATCH] Accept subscription status = trialing because that is what we will be if we are using the trial period --- datacenterlight/tests.py | 6 ++++-- datacenterlight/views.py | 6 ++++-- hosting/views.py | 4 +++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/datacenterlight/tests.py b/datacenterlight/tests.py index 964a9d5f..74798cc3 100644 --- a/datacenterlight/tests.py +++ b/datacenterlight/tests.py @@ -123,8 +123,10 @@ class CeleryTaskTestCase(TestCase): int(datetime.datetime.now().timestamp()) + 300 if settings.ADD_TRIAL_PERIOD_TO_SUBSCRIPTION else None) stripe_subscription_obj = subscription_result.get('response_object') # Check if the subscription was approved and is active - if stripe_subscription_obj is None \ - or stripe_subscription_obj.status != 'active': + if (stripe_subscription_obj is None or + (stripe_subscription_obj.status != 'active' and + stripe_subscription_obj.status != 'trialing') + ): msg = subscription_result.get('error') raise Exception("Creating subscription failed: {}".format(msg)) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index ffdd4831..b2fd483c 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -791,8 +791,10 @@ class OrderConfirmationView(DetailView, FormView): ) stripe_subscription_obj = subscription_result.get('response_object') # Check if the subscription was approved and is active - if (stripe_subscription_obj is None - or stripe_subscription_obj.status != 'active'): + if (stripe_subscription_obj is None or + (stripe_subscription_obj.status != 'active' and + stripe_subscription_obj.status != 'trialing') + ): # At this point, we have created a Stripe API card and # associated it with the customer; but the transaction failed # due to some reason. So, we would want to dissociate this card diff --git a/hosting/views.py b/hosting/views.py index ff45b0db..729c402f 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -1039,7 +1039,9 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView, FormView): stripe_subscription_obj = subscription_result.get('response_object') # Check if the subscription was approved and is active if (stripe_subscription_obj is None or - stripe_subscription_obj.status != 'active'): + (stripe_subscription_obj.status != 'active' and + stripe_subscription_obj.status != 'trialing') + ): # At this point, we have created a Stripe API card and # associated it with the customer; but the transaction failed # due to some reason. So, we would want to dissociate this card