From 132480c031dc38f7749dec789aaac4a1bf8bc911 Mon Sep 17 00:00:00 2001 From: Vishnu Ks Date: Wed, 8 Aug 2018 11:17:10 +0000 Subject: [PATCH] billing: Pass email to stripe.Customer.create. --- stubs/stripe/__init__.pyi | 3 ++- zilencer/lib/stripe.py | 1 + zilencer/tests/stripe_fixtures.json | 4 ++-- zilencer/tests/test_stripe.py | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/stubs/stripe/__init__.pyi b/stubs/stripe/__init__.pyi index 4d733ed76a..4cbaf7d85c 100644 --- a/stubs/stripe/__init__.pyi +++ b/stubs/stripe/__init__.pyi @@ -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: diff --git a/zilencer/lib/stripe.py b/zilencer/lib/stripe.py index 0242293b73..05673f6a7f 100644 --- a/zilencer/lib/stripe.py +++ b/zilencer/lib/stripe.py @@ -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: diff --git a/zilencer/tests/stripe_fixtures.json b/zilencer/tests/stripe_fixtures.json index 741ddc92d9..010698031d 100644 --- a/zilencer/tests/stripe_fixtures.json +++ b/zilencer/tests/stripe_fixtures.json @@ -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, diff --git a/zilencer/tests/test_stripe.py b/zilencer/tests/test_stripe.py index 573b515ae2..e5465b39ec 100644 --- a/zilencer/tests/test_stripe.py +++ b/zilencer/tests/test_stripe.py @@ -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(