Create stripe customer if not exists
This commit is contained in:
parent
b44948b277
commit
8b36d9cba4
1 changed files with 6 additions and 2 deletions
|
@ -591,9 +591,13 @@ class OrderConfirmationView(DetailView):
|
||||||
try:
|
try:
|
||||||
custom_user = CustomUser.objects.get(
|
custom_user = CustomUser.objects.get(
|
||||||
email=user.get('email'))
|
email=user.get('email'))
|
||||||
customer = StripeCustomer.objects.filter(
|
stripe_customer = StripeCustomer.objects.filter(
|
||||||
user_id=custom_user.id).first()
|
user_id=custom_user.id).first()
|
||||||
stripe_customer_id = customer.id
|
if stripe_customer is None:
|
||||||
|
stripe_customer = StripeCustomer.objects.create(
|
||||||
|
user=custom_user, stripe_id=stripe_api_cus_id
|
||||||
|
)
|
||||||
|
stripe_customer_id = stripe_customer.id
|
||||||
except CustomUser.DoesNotExist:
|
except CustomUser.DoesNotExist:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Customer {} does not exist.".format(user.get('email')))
|
"Customer {} does not exist.".format(user.get('email')))
|
||||||
|
|
Loading…
Reference in a new issue