Added code to fetch cc data and put in context

This commit is contained in:
PCoder 2017-06-30 11:06:58 +05:30
parent d0376f35f8
commit 4c3d8627b1

View file

@ -362,15 +362,15 @@ class OrderConfirmationView(DetailView):
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
if 'specs' not in request.session or 'user' not in request.session: if 'specs' not in request.session or 'user' not in request.session:
return HttpResponseRedirect(reverse('datacenterlight:index')) return HttpResponseRedirect(reverse('datacenterlight:index'))
print(request.session.get('billing_address_data'))
print(request.session.get('specs'))
stripe_customer_id = request.session.get('customer') stripe_customer_id = request.session.get('customer')
customer = StripeCustomer.objects.filter(id=stripe_customer_id).first() customer = StripeCustomer.objects.filter(id=stripe_customer_id).first()
custom_user = CustomUser.objects.get(email=request.session.get('user').get('email')) stripe_utils = StripeUtils()
print(custom_user) card_details = stripe_utils.get_card_details(customer.stripe_id, request.session.get('token'))
obj = CreditCards.objects.filter(user_id=custom_user.id).first() context = {
print(obj) 'cc_last4' : card_details.get('response_object').get('last4'),
return render(request, self.template_name, {}) 'cc_brand' : card_details.get('response_object').get('brand')
}
return render(request, self.template_name, context)
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
template = request.session.get('template') template = request.session.get('template')