From 4c3d8627b161204e4c10e10f8f2f91e051fe2e12 Mon Sep 17 00:00:00 2001 From: PCoder Date: Fri, 30 Jun 2017 11:06:58 +0530 Subject: [PATCH] Added code to fetch cc data and put in context --- datacenterlight/views.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 628d0c03..8e8858c6 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -362,15 +362,15 @@ class OrderConfirmationView(DetailView): def get(self, request, *args, **kwargs): if 'specs' not in request.session or 'user' not in request.session: return HttpResponseRedirect(reverse('datacenterlight:index')) - print(request.session.get('billing_address_data')) - print(request.session.get('specs')) stripe_customer_id = request.session.get('customer') customer = StripeCustomer.objects.filter(id=stripe_customer_id).first() - custom_user = CustomUser.objects.get(email=request.session.get('user').get('email')) - print(custom_user) - obj = CreditCards.objects.filter(user_id=custom_user.id).first() - print(obj) - return render(request, self.template_name, {}) + stripe_utils = StripeUtils() + card_details = stripe_utils.get_card_details(customer.stripe_id, request.session.get('token')) + context = { + 'cc_last4' : card_details.get('response_object').get('last4'), + 'cc_brand' : card_details.get('response_object').get('brand') + } + return render(request, self.template_name, context) def post(self, request, *args, **kwargs): template = request.session.get('template')