billing: Pass email to stripe.Customer.create.

This commit is contained in:
Vishnu Ks 2018-08-08 11:17:10 +00:00 committed by Rishi Gupta
parent 9946202148
commit 132480c031
4 changed files with 6 additions and 3 deletions

View File

@ -17,7 +17,8 @@ class Customer:
...
@staticmethod
def create(description: str, metadata: Dict[str, Any], source: str) -> Customer:
def create(description: str, email: str, metadata: Dict[str, Any],
source: str) -> Customer:
...
class Invoice:

View File

@ -122,6 +122,7 @@ def do_create_customer_with_payment_source(user: UserProfile, stripe_token: str)
realm = user.realm
stripe_customer = stripe.Customer.create(
description="%s (%s)" % (realm.string_id, realm.name),
email=user.email,
metadata={'realm_id': realm.id, 'realm_str': realm.string_id},
source=stripe_token)
if PRINT_STRIPE_FIXTURE_DATA:

View File

@ -7,7 +7,7 @@
"delinquent": false,
"description": "zulip (Zulip Dev)",
"discount": null,
"email": null,
"email": "hamlet@zulip.com",
"id": "cus_D7OT2jf5YAtZQL",
"invoice_prefix": "23ABC45",
"livemode": false,
@ -166,7 +166,7 @@
"delinquent": false,
"description": "zulip (Zulip Dev)",
"discount": null,
"email": null,
"email": "hamlet@zulip.com",
"id": "cus_D7OT2jf5YAtZQL",
"invoice_prefix": "23ABC45",
"livemode": false,

View File

@ -99,6 +99,7 @@ class StripeTest(ZulipTestCase):
# Check that we created a customer and subscription in stripe
mock_create_customer.assert_called_once_with(
description="zulip (Zulip Dev)",
email=user.email,
metadata={'realm_id': user.realm.id, 'realm_str': 'zulip'},
source=self.token)
mock_create_subscription.assert_called_once_with(