Use hasattr to check if a user already has a stripecustomer object
This commit is contained in:
parent
8d2c120b43
commit
ef9dc446db
2 changed files with 12 additions and 8 deletions
|
|
@ -664,8 +664,12 @@ class PaymentVMView(LoginRequiredMixin, FormView):
|
|||
def get_context_data(self, **kwargs):
|
||||
context = super(PaymentVMView, self).get_context_data(**kwargs)
|
||||
user = self.request.user
|
||||
if hasattr(user, 'stripecustomer'):
|
||||
stripe_customer = user.stripecustomer
|
||||
else:
|
||||
stripe_customer = None
|
||||
cards_list = UserCardDetail.get_all_cards_list(
|
||||
stripe_customer= user.stripecustomer
|
||||
stripe_customer=stripe_customer
|
||||
)
|
||||
context.update({
|
||||
'cards_list': cards_list,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue