mirror of https://github.com/zulip/zulip.git
stripe: Separate activation of free trial for remote realm/server.
Add a separate setting to only enable free trial for remote realm / server.
This commit is contained in:
parent
ccd60bc7e2
commit
ce56e19d1c
|
@ -1813,10 +1813,16 @@ class BillingSession(ABC):
|
|||
free_trial_end_date = None
|
||||
# Don't show free trial for remote servers on legacy plan.
|
||||
if remote_server_legacy_plan_end_date is None:
|
||||
free_trial_days = get_free_trial_days()
|
||||
is_self_hosted_billing = not isinstance(self, RealmBillingSession)
|
||||
free_trial_days = get_free_trial_days(is_self_hosted_billing)
|
||||
if free_trial_days is not None:
|
||||
_, _, free_trial_end, _ = compute_plan_parameters(
|
||||
tier, False, CustomerPlan.BILLING_SCHEDULE_ANNUAL, None, True
|
||||
tier,
|
||||
False,
|
||||
CustomerPlan.BILLING_SCHEDULE_ANNUAL,
|
||||
None,
|
||||
True,
|
||||
is_self_hosted_billing=is_self_hosted_billing,
|
||||
)
|
||||
free_trial_end_date = (
|
||||
f"{free_trial_end:%B} {free_trial_end.day}, {free_trial_end.year}"
|
||||
|
@ -3600,6 +3606,7 @@ def compute_plan_parameters(
|
|||
discount: Optional[Decimal],
|
||||
free_trial: bool = False,
|
||||
billing_cycle_anchor: Optional[datetime] = None,
|
||||
is_self_hosted_billing: bool = False,
|
||||
) -> Tuple[datetime, datetime, datetime, int]:
|
||||
# Everything in Stripe is stored as timestamps with 1 second resolution,
|
||||
# so standardize on 1 second resolution.
|
||||
|
@ -3621,13 +3628,16 @@ def compute_plan_parameters(
|
|||
next_invoice_date = add_months(billing_cycle_anchor, 1)
|
||||
if free_trial:
|
||||
period_end = billing_cycle_anchor + timedelta(
|
||||
days=assert_is_not_none(get_free_trial_days())
|
||||
days=assert_is_not_none(get_free_trial_days(is_self_hosted_billing))
|
||||
)
|
||||
next_invoice_date = period_end
|
||||
return billing_cycle_anchor, next_invoice_date, period_end, price_per_license
|
||||
|
||||
|
||||
def get_free_trial_days() -> Optional[int]:
|
||||
def get_free_trial_days(is_self_hosted_billing: bool = False) -> Optional[int]:
|
||||
if is_self_hosted_billing:
|
||||
return settings.SELF_HOSTING_FREE_TRIAL_DAYS
|
||||
|
||||
return settings.CLOUD_FREE_TRIAL_DAYS
|
||||
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ def plans_view(request: HttpRequest) -> HttpResponse:
|
|||
context = PlansPageContext(
|
||||
is_cloud_realm=True,
|
||||
sponsorship_url=reverse("sponsorship_request"),
|
||||
free_trial_days=get_free_trial_days(),
|
||||
free_trial_days=get_free_trial_days(False),
|
||||
is_sponsored=realm is not None and realm.plan_type == Realm.PLAN_TYPE_STANDARD_FREE,
|
||||
)
|
||||
if is_subdomain_root_or_alias(request):
|
||||
|
@ -137,7 +137,7 @@ def remote_realm_plans_page(
|
|||
sponsorship_url=reverse(
|
||||
"remote_realm_sponsorship_page", args=(billing_session.remote_realm.uuid,)
|
||||
),
|
||||
free_trial_days=get_free_trial_days(),
|
||||
free_trial_days=get_free_trial_days(True),
|
||||
billing_base_url=billing_session.billing_base_url,
|
||||
is_sponsored=billing_session.is_sponsored(),
|
||||
)
|
||||
|
@ -172,7 +172,7 @@ def remote_server_plans_page(
|
|||
sponsorship_url=reverse(
|
||||
"remote_server_sponsorship_page", args=(billing_session.remote_server.uuid,)
|
||||
),
|
||||
free_trial_days=get_free_trial_days(),
|
||||
free_trial_days=get_free_trial_days(True),
|
||||
billing_base_url=billing_session.billing_base_url,
|
||||
is_sponsored=billing_session.is_sponsored(),
|
||||
)
|
||||
|
|
|
@ -547,6 +547,7 @@ ARCHIVED_DATA_VACUUMING_DELAY_DAYS = 30
|
|||
BILLING_ENABLED = False
|
||||
|
||||
CLOUD_FREE_TRIAL_DAYS: Optional[int] = int(get_secret("cloud_free_trial_days", "0"))
|
||||
SELF_HOSTING_FREE_TRIAL_DAYS: Optional[int] = int(get_secret("self_hosting_free_trial_days", "0"))
|
||||
|
||||
# Custom message (supports HTML) to be shown in the navbar of landing pages. Used mainly for
|
||||
# making announcements.
|
||||
|
|
Loading…
Reference in New Issue