mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	stripe: Use a function to get free trial days.
This commit is contained in:
		@@ -1813,7 +1813,7 @@ 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 = settings.FREE_TRIAL_DAYS
 | 
			
		||||
            free_trial_days = get_free_trial_days()
 | 
			
		||||
            if free_trial_days is not None:
 | 
			
		||||
                _, _, free_trial_end, _ = compute_plan_parameters(
 | 
			
		||||
                    tier, False, CustomerPlan.BILLING_SCHEDULE_ANNUAL, None, True
 | 
			
		||||
@@ -3621,12 +3621,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(settings.FREE_TRIAL_DAYS)
 | 
			
		||||
            days=assert_is_not_none(get_free_trial_days())
 | 
			
		||||
        )
 | 
			
		||||
        next_invoice_date = period_end
 | 
			
		||||
    return billing_cycle_anchor, next_invoice_date, period_end, price_per_license
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_free_trial_days() -> Optional[int]:
 | 
			
		||||
    return settings.FREE_TRIAL_DAYS
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def is_free_trial_offer_enabled() -> bool:
 | 
			
		||||
    return settings.FREE_TRIAL_DAYS not in (None, 0)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,11 @@ from corporate.lib.decorator import (
 | 
			
		||||
    authenticated_remote_realm_management_endpoint,
 | 
			
		||||
    authenticated_remote_server_management_endpoint,
 | 
			
		||||
)
 | 
			
		||||
from corporate.lib.stripe import RemoteRealmBillingSession, RemoteServerBillingSession
 | 
			
		||||
from corporate.lib.stripe import (
 | 
			
		||||
    RemoteRealmBillingSession,
 | 
			
		||||
    RemoteServerBillingSession,
 | 
			
		||||
    get_free_trial_days,
 | 
			
		||||
)
 | 
			
		||||
from corporate.models import CustomerPlan, get_current_plan_by_customer, get_customer_by_realm
 | 
			
		||||
from zerver.context_processors import get_realm_from_request, latest_info_context
 | 
			
		||||
from zerver.decorator import add_google_analytics
 | 
			
		||||
@@ -86,7 +90,7 @@ def plans_view(request: HttpRequest) -> HttpResponse:
 | 
			
		||||
    context = PlansPageContext(
 | 
			
		||||
        is_cloud_realm=True,
 | 
			
		||||
        sponsorship_url=reverse("sponsorship_request"),
 | 
			
		||||
        free_trial_days=settings.FREE_TRIAL_DAYS,
 | 
			
		||||
        free_trial_days=get_free_trial_days(),
 | 
			
		||||
        is_sponsored=realm is not None and realm.plan_type == Realm.PLAN_TYPE_STANDARD_FREE,
 | 
			
		||||
    )
 | 
			
		||||
    if is_subdomain_root_or_alias(request):
 | 
			
		||||
@@ -133,7 +137,7 @@ def remote_realm_plans_page(
 | 
			
		||||
        sponsorship_url=reverse(
 | 
			
		||||
            "remote_realm_sponsorship_page", args=(billing_session.remote_realm.uuid,)
 | 
			
		||||
        ),
 | 
			
		||||
        free_trial_days=settings.FREE_TRIAL_DAYS,
 | 
			
		||||
        free_trial_days=get_free_trial_days(),
 | 
			
		||||
        billing_base_url=billing_session.billing_base_url,
 | 
			
		||||
        is_sponsored=billing_session.is_sponsored(),
 | 
			
		||||
    )
 | 
			
		||||
@@ -168,7 +172,7 @@ def remote_server_plans_page(
 | 
			
		||||
        sponsorship_url=reverse(
 | 
			
		||||
            "remote_server_sponsorship_page", args=(billing_session.remote_server.uuid,)
 | 
			
		||||
        ),
 | 
			
		||||
        free_trial_days=settings.FREE_TRIAL_DAYS,
 | 
			
		||||
        free_trial_days=get_free_trial_days(),
 | 
			
		||||
        billing_base_url=billing_session.billing_base_url,
 | 
			
		||||
        is_sponsored=billing_session.is_sponsored(),
 | 
			
		||||
    )
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user