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.

billing: Create is_free_trial_offer_enabled function.

Vishnu KS6e3d4e7e7562
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py
index 074906586f3..5dfd6886221 100644
--- a/corporate/lib/stripe.py
+++ b/corporate/lib/stripe.py
@@ -501,6 +501,10 @@ def decimal_to_float(obj: object) -> object:
raise TypeError # nocoverage
+def is_free_trial_offer_enabled() -> bool:
+ return settings.FREE_TRIAL_DAYS not in (None, 0)
+
+
# Only used for cloud signups
@catch_stripe_errors
def process_initial_upgrade(
@@ -513,7 +517,7 @@ def process_initial_upgrade(
realm = user.realm
customer = update_or_create_stripe_customer(user, stripe_token=stripe_token)
charge_automatically = stripe_token is not None
- free_trial = settings.FREE_TRIAL_DAYS not in (None, 0)
+ free_trial = is_free_trial_offer_enabled()
if get_current_plan_by_customer(customer) is not None:
# Unlikely race condition from two people upgrading (clicking "Make payment")
diff --git a/zerver/views/auth.py b/zerver/views/auth.py
index a1fe2630319..58e7a38d7cc 100644
--- a/zerver/views/auth.py
+++ b/zerver/views/auth.py
@@ -294,8 +294,11 @@ def login_or_register_remote_user(request: HttpRequest, result: ExternalAuthResu
do_login(request, user_profile)
redirect_to = result.data_dict.get("redirect_to", "")
- if is_realm_creation is not None and settings.FREE_TRIAL_DAYS not in [None, 0]:
- redirect_to = "{}?onboarding=true".format(reverse("initial_upgrade"))
+ if is_realm_creation is not None and settings.BILLING_ENABLED:
+ from corporate.lib.stripe import is_free_trial_offer_enabled
+
+ if is_free_trial_offer_enabled():
+ redirect_to = "{}?onboarding=true".format(reverse("initial_upgrade"))
redirect_to = get_safe_redirect_to(redirect_to, user_profile.realm.uri)
return HttpResponseRedirect(redirect_to)