Associate newly added card with customer from hosting

This commit is contained in:
M.Ravi 2017-10-26 12:29:16 +02:00
parent de5035d12e
commit 8d2c120b43
2 changed files with 6 additions and 2 deletions

View file

@ -626,6 +626,10 @@ class SettingsView(LoginRequiredMixin, FormView):
exp_year=card_details_response['exp_year'], exp_year=card_details_response['exp_year'],
card_id=card_details_response['card_id'] card_id=card_details_response['card_id']
) )
stripe_utils.associate_customer_card(
request.user.stripecustomer.stripe_id,
token
)
msg = _( msg = _(
"Successfully associated the card with your account" "Successfully associated the card with your account"
) )

View file

@ -212,8 +212,8 @@ class StripeCustomer(models.Model):
stripe_customer.user, token) stripe_customer.user, token)
if "deleted" in customer and customer["deleted"]: if "deleted" in customer and customer["deleted"]:
raise StripeCustomer.DoesNotExist() raise StripeCustomer.DoesNotExist()
if not customer.sources.data: #if not customer.sources.data:
stripe_utils.update_customer_token(customer, token) # stripe_utils.update_customer_token(customer, token)
return stripe_customer return stripe_customer
except StripeCustomer.DoesNotExist: except StripeCustomer.DoesNotExist:
user = CustomUser.objects.get(email=email) user = CustomUser.objects.get(email=email)