Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

corporate: Restrict free-trial when fixed-price plan is configured.

Prakhar Pratyush82da6abb245b
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py
index 9fef1dab815..94d996e8900 100644
--- a/corporate/lib/stripe.py
+++ b/corporate/lib/stripe.py
@@ -1656,8 +1656,16 @@ class BillingSession(ABC):
"monthly": CustomerPlan.BILLING_SCHEDULE_MONTHLY,
}[schedule]
data: Dict[str, Any] = {}
+
is_self_hosted_billing = not isinstance(self, RealmBillingSession)
free_trial = is_free_trial_offer_enabled(is_self_hosted_billing, upgrade_request.tier)
+ if customer is not None:
+ fixed_price_plan_offer = get_configured_fixed_price_plan_offer(
+ customer, upgrade_request.tier
+ )
+ if fixed_price_plan_offer is not None:
+ free_trial = False
+
remote_server_legacy_plan = self.get_remote_server_legacy_plan(customer)
should_schedule_upgrade_for_legacy_remote_server = (
remote_server_legacy_plan is not None
@@ -2225,7 +2233,7 @@ class BillingSession(ABC):
free_trial_end_date = None
# Don't show free trial for remote servers on legacy plan.
is_self_hosted_billing = not isinstance(self, RealmBillingSession)
- if remote_server_legacy_plan_end_date is None:
+ if fixed_price is None and remote_server_legacy_plan_end_date is None:
free_trial_days = get_free_trial_days(is_self_hosted_billing, tier)
if free_trial_days is not None:
_, _, free_trial_end, _ = compute_plan_parameters(
diff --git a/corporate/views/portico.py b/corporate/views/portico.py
index e768f0fd9a0..d605af05091 100644
--- a/corporate/views/portico.py
+++ b/corporate/views/portico.py
@@ -16,6 +16,7 @@ from corporate.lib.decorator import (
from corporate.lib.stripe import (
RemoteRealmBillingSession,
RemoteServerBillingSession,
+ get_configured_fixed_price_plan_offer,
get_free_trial_days,
)
from corporate.models import CustomerPlan, get_current_plan_by_customer, get_customer_by_realm
@@ -152,6 +153,15 @@ def remote_realm_plans_page(
if customer is not None: # nocoverage
context.sponsorship_pending = customer.sponsorship_pending
context.customer_plan = get_current_plan_by_customer(customer)
+
+ if customer.required_plan_tier is not None:
+ configure_fixed_price_plan = get_configured_fixed_price_plan_offer(
+ customer, customer.required_plan_tier
+ )
+ # Free trial is disabled for customers with fixed-price plan configured.
+ if configure_fixed_price_plan is not None:
+ context.free_trial_days = None
+
if context.customer_plan is None:
context.on_free_tier = not context.is_sponsored
else:
@@ -209,6 +219,15 @@ def remote_server_plans_page(
if customer is not None: # nocoverage
context.sponsorship_pending = customer.sponsorship_pending
context.customer_plan = get_current_plan_by_customer(customer)
+
+ if customer.required_plan_tier is not None:
+ configure_fixed_price_plan = get_configured_fixed_price_plan_offer(
+ customer, customer.required_plan_tier
+ )
+ # Free trial is disabled for customers with fixed-price plan configured.
+ if configure_fixed_price_plan is not None:
+ context.free_trial_days = None
+
if context.customer_plan is None:
context.on_free_tier = not context.is_sponsored
else: