Added CustomUser model reload code

This commit is contained in:
M.Ravi 2017-06-22 23:48:14 +05:30
parent 5caa79f199
commit d4e7eb9511

View file

@ -176,16 +176,14 @@ class StripeCustomer(models.Model):
return stripe_customer
except StripeCustomer.DoesNotExist:
CustomUser.refresh_from_db()
user = CustomUser.objects.get(email=email)
stripe_utils = StripeUtils()
stripe_data = stripe_utils.create_customer(token, email)
if stripe_data.get('response_object'):
stripe_cus_id = stripe_data.get('response_object').get('id')
stripe_customer = StripeCustomer.objects.\
create(user=user, stripe_id=stripe_cus_id)
return stripe_customer
else:
return None