I'm trying a way to figure out how to retrieve the Stripe Customer by e-mail:
In my views, I wrote the below code:
if stripe.Customer.retrieve(email=request.POST['email']):
customer = stripe.Customer.retrieve(id)
else:
customer = stripe.Customer.create(
email=request.POST['email'],
name=request.POST['nickname'],
)
charge = stripe.Charge.create(
customer=customer,
amount=500,
currency='brl',
description='First Test Ever!',
source=request.POST['stripeToken'],
)
Basically, if the customer is found by their e-mail, so I don't need to create a new account. Otherwise, the account is created. The last step is to charge either the new customer or the existent one.
The code is not working properly. I assume this is the wrong way to search for an existent customer.
Any help?
Thank you!