From 3ed6119dc9b58536d0a22aa998a9006d77090489 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 24 Dec 2017 12:53:23 +0100 Subject: [PATCH] Check if DG subscription created was under trial; if not show error --- digitalglarus/views.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/digitalglarus/views.py b/digitalglarus/views.py index ff567036..e163359c 100644 --- a/digitalglarus/views.py +++ b/digitalglarus/views.py @@ -398,10 +398,18 @@ class MembershipPaymentView(LoginRequiredMixin, IsNotMemberMixin, FormView): stripe_subscription_obj = subscription_result.get( 'response_object' ) - # Check if the subscription was approved and is active + # Check if call to create subscription was ok if (stripe_subscription_obj is None or - stripe_subscription_obj.status != 'active'): - pass + ( + stripe_subscription_obj.status != 'active' and + stripe_subscription_obj.status != 'trialing' + ) + ): + context.update({ + 'paymentError': subscription_result.get('error'), + 'form': form + }) + return render(request, self.template_name, context) charge = charge_response.get('response_object') if 'source' in charge: