Now showing cards from UserCardDetails
This commit is contained in:
parent
52791f5e48
commit
619f37829e
1 changed files with 5 additions and 9 deletions
|
@ -549,21 +549,17 @@ class SettingsView(LoginRequiredMixin, FormView):
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(SettingsView, self).get_context_data(**kwargs)
|
context = super(SettingsView, self).get_context_data(**kwargs)
|
||||||
# Get user
|
|
||||||
user = self.request.user
|
user = self.request.user
|
||||||
# Get user's all orders
|
user_card_details = UserCardDetail.objects.filter(
|
||||||
hosting_orders = HostingOrder.objects.filter(customer__user=user)
|
stripe_customer_id=user.stripecustomer.id
|
||||||
# If user has hosting orders, get the credit card data from it
|
)
|
||||||
cards_list = []
|
cards_list = []
|
||||||
for order in hosting_orders:
|
for card in user_card_details:
|
||||||
credit_card_data = order.get_cc_data()
|
cards_list.append({'last4': card.last4, 'brand': card.brand})
|
||||||
if credit_card_data and (credit_card_data not in cards_list):
|
|
||||||
cards_list.append(credit_card_data)
|
|
||||||
context.update({
|
context.update({
|
||||||
'cards_list': cards_list,
|
'cards_list': cards_list,
|
||||||
'stripe_key': settings.STRIPE_API_PUBLIC_KEY
|
'stripe_key': settings.STRIPE_API_PUBLIC_KEY
|
||||||
})
|
})
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
|
|
Loading…
Reference in a new issue