From 83df42b5dfa893ee9bbdaffbab81dd982c258aff Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 22 Aug 2017 00:07:58 +0530 Subject: [PATCH] Fixed checking active status of subscription + redirection to payment page on error --- datacenterlight/views.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 9761b471..91dbf900 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -467,12 +467,10 @@ class OrderConfirmationView(DetailView): 'response_object').stripe_plan_id}]) response_object = subscription_result.get('response_object') # Check if the subscription was approved and is active - if response_object is None or response_object.status is not 'active': - context = {} - context.update({ - 'paymentError': response_object.get('error') - }) - return render(request, self.payment_template_name, context) + if response_object is None or response_object.status != 'active': + msg = subscription_result.get('error') + messages.add_message(self.request, messages.ERROR, msg, extra_tags='failed_payment') + return HttpResponseRedirect(reverse('datacenterlight:payment') + '#payment_error') create_vm_task.delay(vm_template_id, user, specs, template, stripe_customer_id, billing_address_data, billing_address_id, response_object)