Get and show all card details in the landing flow, if the user is logged in

This commit is contained in:
PCoder 2018-07-04 00:50:44 +02:00
parent c118e86230
commit 3d8237a34a

View file

@ -222,19 +222,15 @@ class PaymentOrderView(FormView):
billing_address_form = BillingAddressForm( billing_address_form = BillingAddressForm(
instance=self.request.user.billing_addresses.first() instance=self.request.user.billing_addresses.first()
) )
# Get user last order user = self.request.user
last_hosting_order = HostingOrder.objects.filter( if hasattr(user, 'stripecustomer'):
customer__user=self.request.user stripe_customer = user.stripecustomer
).last() else:
stripe_customer = None
# If user has already an hosting order, get the credit card cards_list = UserCardDetail.get_all_cards_list(
# data from it stripe_customer=stripe_customer
if last_hosting_order: )
credit_card_data = last_hosting_order.get_cc_data() context.update({'cards_list': cards_list})
if credit_card_data:
context['credit_card_data'] = credit_card_data
else:
context['credit_card_data'] = None
else: else:
billing_address_form = BillingAddressFormSignup( billing_address_form = BillingAddressFormSignup(
initial=billing_address_data initial=billing_address_data