billing: Create is_free_trial_offer_enabled function.

This commit is contained in:
Vishnu KS
2020-10-14 13:14:01 +05:30
committed by Tim Abbott
parent 5da3a69505
commit 6e3d4e7e75
2 changed files with 10 additions and 3 deletions

View File

@@ -501,6 +501,10 @@ def decimal_to_float(obj: object) -> object:
raise TypeError # nocoverage raise TypeError # nocoverage
def is_free_trial_offer_enabled() -> bool:
return settings.FREE_TRIAL_DAYS not in (None, 0)
# Only used for cloud signups # Only used for cloud signups
@catch_stripe_errors @catch_stripe_errors
def process_initial_upgrade( def process_initial_upgrade(
@@ -513,7 +517,7 @@ def process_initial_upgrade(
realm = user.realm realm = user.realm
customer = update_or_create_stripe_customer(user, stripe_token=stripe_token) customer = update_or_create_stripe_customer(user, stripe_token=stripe_token)
charge_automatically = stripe_token is not None 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: if get_current_plan_by_customer(customer) is not None:
# Unlikely race condition from two people upgrading (clicking "Make payment") # Unlikely race condition from two people upgrading (clicking "Make payment")

View File

@@ -294,8 +294,11 @@ def login_or_register_remote_user(request: HttpRequest, result: ExternalAuthResu
do_login(request, user_profile) do_login(request, user_profile)
redirect_to = result.data_dict.get("redirect_to", "") redirect_to = result.data_dict.get("redirect_to", "")
if is_realm_creation is not None and settings.FREE_TRIAL_DAYS not in [None, 0]: if is_realm_creation is not None and settings.BILLING_ENABLED:
redirect_to = "{}?onboarding=true".format(reverse("initial_upgrade")) 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) redirect_to = get_safe_redirect_to(redirect_to, user_profile.realm.uri)
return HttpResponseRedirect(redirect_to) return HttpResponseRedirect(redirect_to)