billing: Add comment explaining race condition in customer creation.

This commit is contained in:
Rishi Gupta 2018-08-22 21:44:00 -07:00
parent ca272ef49d
commit 4ad8f20c28
1 changed files with 4 additions and 0 deletions

View File

@ -138,6 +138,10 @@ def extract_current_subscription(stripe_customer: stripe.Customer) -> Any:
@catch_stripe_errors @catch_stripe_errors
def do_create_customer_with_payment_source(user: UserProfile, stripe_token: str) -> stripe.Customer: def do_create_customer_with_payment_source(user: UserProfile, stripe_token: str) -> stripe.Customer:
realm = user.realm realm = user.realm
# We could do a better job of handling race conditions here, but if two
# people from a realm try to upgrade at exactly the same time, the main
# bad thing that will happen is that we will create an extra stripe
# customer that we can delete or ignore.
stripe_customer = stripe.Customer.create( stripe_customer = stripe.Customer.create(
description="%s (%s)" % (realm.string_id, realm.name), description="%s (%s)" % (realm.string_id, realm.name),
email=user.email, email=user.email,