diff --git a/analytics/tests/test_support_views.py b/analytics/tests/test_support_views.py
index a08f4dbc3b..67409eef9f 100644
--- a/analytics/tests/test_support_views.py
+++ b/analytics/tests/test_support_views.py
@@ -434,8 +434,8 @@ class TestSupportEndpoint(ZulipTestCase):
result,
)
- @mock.patch("analytics.views.support.update_realm_billing_method")
- def test_change_billing_method(self, m: mock.Mock) -> None:
+ @mock.patch("analytics.views.support.update_realm_billing_modality")
+ def test_change_billing_modality(self, m: mock.Mock) -> None:
cordelia = self.example_user("cordelia")
self.login_user(cordelia)
@@ -450,21 +450,22 @@ class TestSupportEndpoint(ZulipTestCase):
result = self.client_post(
"/activity/support",
- {"realm_id": f"{iago.realm_id}", "billing_method": "charge_automatically"},
+ {"realm_id": f"{iago.realm_id}", "billing_modality": "charge_automatically"},
)
m.assert_called_once_with(get_realm("zulip"), charge_automatically=True, acting_user=iago)
self.assert_in_success_response(
- ["Billing method of zulip updated to charge automatically"], result
+ ["Billing collection method of zulip updated to charge automatically"], result
)
m.reset_mock()
result = self.client_post(
- "/activity/support", {"realm_id": f"{iago.realm_id}", "billing_method": "send_invoice"}
+ "/activity/support",
+ {"realm_id": f"{iago.realm_id}", "billing_modality": "send_invoice"},
)
m.assert_called_once_with(get_realm("zulip"), charge_automatically=False, acting_user=iago)
self.assert_in_success_response(
- ["Billing method of zulip updated to pay by invoice"], result
+ ["Billing collection method of zulip updated to send invoice"], result
)
def test_change_realm_plan_type(self) -> None:
diff --git a/analytics/views/support.py b/analytics/views/support.py
index 7225a768b8..b1d8d99c41 100644
--- a/analytics/views/support.py
+++ b/analytics/views/support.py
@@ -63,7 +63,7 @@ if settings.BILLING_ENABLED:
attach_discount_to_realm,
get_discount_for_realm,
switch_realm_from_standard_to_plus_plan,
- update_realm_billing_method,
+ update_realm_billing_modality,
update_realm_sponsorship_status,
)
from corporate.models import (
@@ -141,7 +141,7 @@ VALID_STATUS_VALUES = [
"deactivated",
]
-VALID_BILLING_METHODS = [
+VALID_BILLING_MODALITY_VALUES = [
"send_invoice",
"charge_automatically",
]
@@ -164,8 +164,8 @@ def support(
discount: Optional[Decimal] = REQ(default=None, converter=to_decimal),
new_subdomain: Optional[str] = REQ(default=None),
status: Optional[str] = REQ(default=None, str_validator=check_string_in(VALID_STATUS_VALUES)),
- billing_method: Optional[str] = REQ(
- default=None, str_validator=check_string_in(VALID_BILLING_METHODS)
+ billing_modality: Optional[str] = REQ(
+ default=None, str_validator=check_string_in(VALID_BILLING_MODALITY_VALUES)
),
sponsorship_pending: Optional[bool] = REQ(default=None, json_validator=check_bool),
approve_sponsorship: bool = REQ(default=False, json_validator=check_bool),
@@ -236,21 +236,21 @@ def support(
elif status == "deactivated":
do_deactivate_realm(realm, acting_user=acting_user)
context["success_message"] = f"{realm.string_id} deactivated."
- elif billing_method is not None:
- if billing_method == "send_invoice":
- update_realm_billing_method(
+ elif billing_modality is not None:
+ if billing_modality == "send_invoice":
+ update_realm_billing_modality(
realm, charge_automatically=False, acting_user=acting_user
)
context[
"success_message"
- ] = f"Billing method of {realm.string_id} updated to pay by invoice."
- elif billing_method == "charge_automatically":
- update_realm_billing_method(
+ ] = f"Billing collection method of {realm.string_id} updated to send invoice."
+ elif billing_modality == "charge_automatically":
+ update_realm_billing_modality(
realm, charge_automatically=True, acting_user=acting_user
)
context[
"success_message"
- ] = f"Billing method of {realm.string_id} updated to charge automatically."
+ ] = f"Billing collection method of {realm.string_id} updated to charge automatically."
elif sponsorship_pending is not None:
if sponsorship_pending:
update_realm_sponsorship_status(realm, True, acting_user=acting_user)
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py
index 4c97416aad..4cc5803353 100644
--- a/corporate/lib/stripe.py
+++ b/corporate/lib/stripe.py
@@ -529,7 +529,7 @@ class AuditLogEventType(Enum):
DISCOUNT_CHANGED = 4
SPONSORSHIP_APPROVED = 5
SPONSORSHIP_PENDING_STATUS_CHANGED = 6
- BILLING_METHOD_CHANGED = 7
+ BILLING_MODALITY_CHANGED = 7
CUSTOMER_SWITCHED_FROM_MONTHLY_TO_ANNUAL_PLAN = 8
CUSTOMER_SWITCHED_FROM_ANNUAL_TO_MONTHLY_PLAN = 9
@@ -902,7 +902,7 @@ class BillingSession(ABC):
extra_data={"sponsorship_pending": sponsorship_pending},
)
- def update_billing_method_of_current_plan(self, charge_automatically: bool) -> None:
+ def update_billing_modality_of_current_plan(self, charge_automatically: bool) -> None:
customer = self.get_customer()
if customer is not None:
plan = get_current_plan_by_customer(customer)
@@ -910,7 +910,7 @@ class BillingSession(ABC):
plan.charge_automatically = charge_automatically
plan.save(update_fields=["charge_automatically"])
self.write_to_audit_log(
- event_type=AuditLogEventType.BILLING_METHOD_CHANGED,
+ event_type=AuditLogEventType.BILLING_MODALITY_CHANGED,
event_time=timezone_now(),
extra_data={"charge_automatically": charge_automatically},
)
@@ -2049,8 +2049,8 @@ class RealmBillingSession(BillingSession):
return RealmAuditLog.REALM_SPONSORSHIP_APPROVED
elif event_type is AuditLogEventType.SPONSORSHIP_PENDING_STATUS_CHANGED:
return RealmAuditLog.REALM_SPONSORSHIP_PENDING_STATUS_CHANGED
- elif event_type is AuditLogEventType.BILLING_METHOD_CHANGED:
- return RealmAuditLog.REALM_BILLING_METHOD_CHANGED
+ elif event_type is AuditLogEventType.BILLING_MODALITY_CHANGED:
+ return RealmAuditLog.REALM_BILLING_MODALITY_CHANGED
elif event_type is AuditLogEventType.CUSTOMER_SWITCHED_FROM_MONTHLY_TO_ANNUAL_PLAN:
return RealmAuditLog.CUSTOMER_SWITCHED_FROM_MONTHLY_TO_ANNUAL_PLAN
elif event_type is AuditLogEventType.CUSTOMER_SWITCHED_FROM_ANNUAL_TO_MONTHLY_PLAN:
@@ -2359,8 +2359,8 @@ class RemoteRealmBillingSession(BillingSession): # nocoverage
return RemoteRealmAuditLog.REMOTE_SERVER_SPONSORSHIP_APPROVED
elif event_type is AuditLogEventType.SPONSORSHIP_PENDING_STATUS_CHANGED:
return RemoteRealmAuditLog.REMOTE_SERVER_SPONSORSHIP_PENDING_STATUS_CHANGED
- elif event_type is AuditLogEventType.BILLING_METHOD_CHANGED:
- return RemoteRealmAuditLog.REMOTE_SERVER_BILLING_METHOD_CHANGED
+ elif event_type is AuditLogEventType.BILLING_MODALITY_CHANGED:
+ return RemoteRealmAuditLog.REMOTE_SERVER_BILLING_MODALITY_CHANGED
else:
raise BillingSessionAuditLogEventError(event_type)
@@ -2632,8 +2632,8 @@ class RemoteServerBillingSession(BillingSession): # nocoverage
return RemoteZulipServerAuditLog.REMOTE_SERVER_SPONSORSHIP_APPROVED
elif event_type is AuditLogEventType.SPONSORSHIP_PENDING_STATUS_CHANGED:
return RemoteZulipServerAuditLog.REMOTE_SERVER_SPONSORSHIP_PENDING_STATUS_CHANGED
- elif event_type is AuditLogEventType.BILLING_METHOD_CHANGED:
- return RemoteZulipServerAuditLog.REMOTE_SERVER_BILLING_METHOD_CHANGED
+ elif event_type is AuditLogEventType.BILLING_MODALITY_CHANGED:
+ return RemoteZulipServerAuditLog.REMOTE_SERVER_BILLING_MODALITY_CHANGED
else:
raise BillingSessionAuditLogEventError(event_type)
diff --git a/corporate/lib/support.py b/corporate/lib/support.py
index 401b20dc08..bbccaa5471 100644
--- a/corporate/lib/support.py
+++ b/corporate/lib/support.py
@@ -43,11 +43,11 @@ def update_realm_sponsorship_status(
billing_session.update_customer_sponsorship_status(sponsorship_pending)
-def update_realm_billing_method(
+def update_realm_billing_modality(
realm: Realm, charge_automatically: bool, *, acting_user: UserProfile
) -> None:
billing_session = RealmBillingSession(acting_user, realm, support_session=True)
- billing_session.update_billing_method_of_current_plan(charge_automatically)
+ billing_session.update_billing_modality_of_current_plan(charge_automatically)
def switch_realm_from_standard_to_plus_plan(realm: Realm) -> None:
diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py
index fa8c97ae49..1c5d32fe26 100644
--- a/corporate/tests/test_stripe.py
+++ b/corporate/tests/test_stripe.py
@@ -79,7 +79,7 @@ from corporate.lib.support import (
attach_discount_to_realm,
get_discount_for_realm,
switch_realm_from_standard_to_plus_plan,
- update_realm_billing_method,
+ update_realm_billing_modality,
update_realm_sponsorship_status,
)
from corporate.models import (
@@ -5234,7 +5234,7 @@ class TestSupportBillingHelpers(StripeTestCase):
self.assertEqual(realm_audit_log.extra_data, expected_extra_data)
self.assertEqual(realm_audit_log.acting_user, iago)
- def test_update_realm_billing_method(self) -> None:
+ def test_update_realm_billing_modality(self) -> None:
realm = get_realm("zulip")
customer = Customer.objects.create(realm=realm, stripe_customer_id="cus_12345")
plan = CustomerPlan.objects.create(
@@ -5247,22 +5247,22 @@ class TestSupportBillingHelpers(StripeTestCase):
self.assertEqual(plan.charge_automatically, False)
iago = self.example_user("iago")
- update_realm_billing_method(realm, True, acting_user=iago)
+ update_realm_billing_modality(realm, True, acting_user=iago)
plan.refresh_from_db()
self.assertEqual(plan.charge_automatically, True)
realm_audit_log = RealmAuditLog.objects.filter(
- event_type=RealmAuditLog.REALM_BILLING_METHOD_CHANGED
+ event_type=RealmAuditLog.REALM_BILLING_MODALITY_CHANGED
).last()
assert realm_audit_log is not None
expected_extra_data = {"charge_automatically": plan.charge_automatically}
self.assertEqual(realm_audit_log.acting_user, iago)
self.assertEqual(realm_audit_log.extra_data, expected_extra_data)
- update_realm_billing_method(realm, False, acting_user=iago)
+ update_realm_billing_modality(realm, False, acting_user=iago)
plan.refresh_from_db()
self.assertEqual(plan.charge_automatically, False)
realm_audit_log = RealmAuditLog.objects.filter(
- event_type=RealmAuditLog.REALM_BILLING_METHOD_CHANGED
+ event_type=RealmAuditLog.REALM_BILLING_MODALITY_CHANGED
).last()
assert realm_audit_log is not None
expected_extra_data = {"charge_automatically": plan.charge_automatically}
diff --git a/templates/analytics/realm_details.html b/templates/analytics/realm_details.html
index d7e6e81abd..1114e7f4f8 100644
--- a/templates/analytics/realm_details.html
+++ b/templates/analytics/realm_details.html
@@ -123,12 +123,12 @@
Next invoice date: {{ plan_data[realm.id].current_plan.next_invoice_date.strftime('%d %B %Y') }}
-