Skip to content

Commit 77781b1

Browse files
authored
Subscriptions: match stripe customer description with org name (#9976)
1 parent bb1ab6c commit 77781b1

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

readthedocs/subscriptions/signals.py

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ def update_stripe_customer(sender, instance, created, **kwargs):
5151
if organization.email != stripe_customer.email:
5252
fields_to_update["email"] = organization.email
5353

54+
if organization.name != stripe_customer.description:
55+
fields_to_update["description"] = organization.name
56+
5457
org_metadata = organization.get_stripe_metadata()
5558
current_metadata = stripe_customer.metadata or {}
5659
for key, value in org_metadata.items():

readthedocs/subscriptions/tests/test_signals.py

+12
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ def setUp(self):
1919
self.organization = get(
2020
Organization,
2121
slug="org",
22+
name="org",
2223
owners=[self.user],
2324
email=email,
2425
stripe_customer=self.stripe_customer,
2526
)
2627
self.stripe_customer.metadata = self.organization.get_stripe_metadata()
28+
self.stripe_customer.description = self.organization.name
2729
self.stripe_customer.save()
2830

2931
@mock.patch("readthedocs.subscriptions.signals.stripe.Customer")
@@ -36,6 +38,16 @@ def test_update_organization_email(self, customer):
3638
email=new_email,
3739
)
3840

41+
@mock.patch("readthedocs.subscriptions.signals.stripe.Customer")
42+
def test_update_organization_name(self, customer):
43+
new_name = "New organization"
44+
self.organization.name = new_name
45+
self.organization.save()
46+
customer.modify.assert_called_once_with(
47+
self.stripe_customer.id,
48+
description=new_name,
49+
)
50+
3951
@mock.patch("readthedocs.subscriptions.signals.stripe.Customer")
4052
def test_update_organization_slug(self, customer):
4153
new_slug = "new-org"

0 commit comments

Comments
 (0)