Here's the relevant code. I'm using Django, with stripe-python (2.46.0) along with dj-stripe (2.3.0).
import stripe
from djstripe.models import Customer
customer, created = Customer.get_or_create(subscriber=my_django_user)
stripe_session = stripe.checkout.Session.create(
customer=customer,
...
)
When the my_django_user.email
field is empty, this works just fine and the stripe_session
is created successfully. But if the email is set, the session creation fails with "No such customer":
stripe.error.InvalidRequestError: Request req_bla: No such customer: <my_django_user's email>
Please correct me if I'm wrong but I don't think this is duplicate of this question because Customer.get_or_create
makes an API request to stripe and so does stripe.checkout.Session.create
, and IIUC both requests are handled under the same account. (Also the above code works with a brand new user, as long as the email's empty.)
Thanks in advance for any help!