- """
- end
-
attr(:user, :map, required: true)
attr(:dismissable, :boolean, default: true)
@@ -520,7 +487,7 @@ defmodule PlausibleWeb.Components.Billing do
"""
end
- def upgrade_link(%{business_tier: true} = assigns) do
+ def upgrade_link(assigns) do
~H"""
- Upgrade
-
- """
- end
-
defp subscription_cancelled_notice_body(assigns) do
if Plausible.Billing.Subscriptions.expired?(assigns.user.subscription) do
~H"""
- <.link class="underline inline-block" href={Plausible.Billing.upgrade_route_for(@user)}>
+ <.link
+ class="underline inline-block"
+ href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}
+ >
Upgrade your subscription
to get access to your stats again.
@@ -553,7 +513,10 @@ defmodule PlausibleWeb.Components.Billing do
~H"""
You have access to your stats until <%= Timex.format!(@user.subscription.next_bill_date, "{Mshort} {D}, {YYYY}") %>.
- <.link class="underline inline-block" href={Plausible.Billing.upgrade_route_for(@user)}>
+ <.link
+ class="underline inline-block"
+ href={Routes.billing_path(PlausibleWeb.Endpoint, :choose_plan)}
+ >
Upgrade your subscription
to make sure you don't lose access.
@@ -563,10 +526,9 @@ defmodule PlausibleWeb.Components.Billing do
end
end
- defp lose_grandfathering_warning(%{user: %{subscription: subscription} = user} = assigns) do
- business_tiers_available? = FunWithFlags.enabled?(:business_tier, for: user)
+ defp lose_grandfathering_warning(%{user: %{subscription: subscription}} = assigns) do
plan = Plans.get_regular_plan(subscription, only_non_expired: true)
- loses_grandfathering = business_tiers_available? && plan && plan.generation < 4
+ loses_grandfathering = plan && plan.generation < 4
assigns = assign(assigns, :loses_grandfathering, loses_grandfathering)
diff --git a/lib/plausible_web/controllers/billing_controller.ex b/lib/plausible_web/controllers/billing_controller.ex
index 6273a9f4e..c0a384dd2 100644
--- a/lib/plausible_web/controllers/billing_controller.ex
+++ b/lib/plausible_web/controllers/billing_controller.ex
@@ -13,48 +13,18 @@ defmodule PlausibleWeb.BillingController do
json(conn, %{is_subscribed: subscribed?})
end
- def upgrade(conn, _params) do
- user = conn.assigns[:current_user]
-
- cond do
- Plausible.Auth.enterprise_configured?(user) ->
- redirect(conn, to: Routes.billing_path(conn, :upgrade_to_enterprise_plan))
-
- FunWithFlags.enabled?(:business_tier, for: user) ->
- redirect(conn, to: Routes.billing_path(conn, :choose_plan))
-
- Subscription.Status.active?(user.subscription) ->
- redirect(conn, to: Routes.billing_path(conn, :change_plan_form))
-
- true ->
- render(conn, "upgrade.html",
- skip_plausible_tracking: true,
- usage: Plausible.Billing.Quota.usage_cycle(user, :last_30_days).total,
- user: user,
- layout: {PlausibleWeb.LayoutView, "focus.html"}
- )
- end
- end
-
def choose_plan(conn, _params) do
user = conn.assigns.current_user
- if FunWithFlags.enabled?(:business_tier, for: user) do
- if Plausible.Auth.enterprise_configured?(user) do
- redirect(conn, to: Routes.billing_path(conn, :upgrade_to_enterprise_plan))
- else
- render(conn, "choose_plan.html",
- skip_plausible_tracking: true,
- user: user,
- layout: {PlausibleWeb.LayoutView, "focus.html"},
- connect_live_socket: true
- )
- end
+ if Plausible.Auth.enterprise_configured?(user) do
+ redirect(conn, to: Routes.billing_path(conn, :upgrade_to_enterprise_plan))
else
- # This will be needed in case we need to flip back the flag.
- # With the :business_tier flag enabled we'll have sent emails
- # linking to `/billing/choose-plan`.
- redirect(conn, to: Routes.billing_path(conn, :upgrade))
+ render(conn, "choose_plan.html",
+ skip_plausible_tracking: true,
+ user: user,
+ layout: {PlausibleWeb.LayoutView, "focus.html"},
+ connect_live_socket: true
+ )
end
end
@@ -95,61 +65,23 @@ defmodule PlausibleWeb.BillingController do
end
end
- def upgrade_enterprise_plan(conn, _params) do
- # DEPRECATED - For some time we need to ensure that the existing
- # links sent out to customers will lead the user to the right place
- redirect(conn, to: Routes.billing_path(conn, :upgrade_to_enterprise_plan))
- end
-
def upgrade_success(conn, _params) do
render(conn, "upgrade_success.html", layout: {PlausibleWeb.LayoutView, "focus.html"})
end
- def change_plan_form(conn, _params) do
- user = conn.assigns[:current_user]
-
- subscription = Billing.active_subscription_for(user.id)
-
- cond do
- FunWithFlags.enabled?(:business_tier, for: user) ->
- render_error(conn, 404)
-
- Plausible.Auth.enterprise_configured?(user) ->
- redirect(conn, to: Routes.billing_path(conn, :upgrade_to_enterprise_plan))
+ def change_plan_preview(conn, %{"plan_id" => new_plan_id}) do
+ user = conn.assigns.current_user
- subscription ->
- render(conn, "change_plan.html",
+ case preview_subscription(user, new_plan_id) do
+ {:ok, {subscription, preview_info}} ->
+ render(conn, "change_plan_preview.html",
+ back_link: Routes.billing_path(conn, :choose_plan),
skip_plausible_tracking: true,
subscription: subscription,
+ preview_info: preview_info,
layout: {PlausibleWeb.LayoutView, "focus.html"}
)
- true ->
- redirect(conn, to: Routes.billing_path(conn, :upgrade))
- end
- end
-
- def change_enterprise_plan(conn, _params) do
- # DEPRECATED - For some time we need to ensure that the existing
- # links sent out to customers will lead the user to the right place
- redirect(conn, to: Routes.billing_path(conn, :upgrade_to_enterprise_plan))
- end
-
- def change_plan_preview(conn, %{"plan_id" => new_plan_id}) do
- user = conn.assigns.current_user
- business_tier_enabled? = FunWithFlags.enabled?(:business_tier, for: user)
-
- with {:ok, {subscription, preview_info}} <- preview_subscription(user, new_plan_id) do
- back_action = if business_tier_enabled?, do: :choose_plan, else: :change_plan_form
-
- render(conn, "change_plan_preview.html",
- back_link: Routes.billing_path(conn, back_action),
- skip_plausible_tracking: true,
- subscription: subscription,
- preview_info: preview_info,
- layout: {PlausibleWeb.LayoutView, "focus.html"}
- )
- else
_ ->
msg =
"Something went wrong with loading your plan change information. Please try again, or contact us at support@plausible.io if the issue persists."
@@ -164,7 +96,7 @@ defmodule PlausibleWeb.BillingController do
conn
|> put_flash(:error, msg)
- |> redirect(to: Plausible.Billing.upgrade_route_for(user))
+ |> redirect(to: Routes.billing_path(conn, :choose_plan))
end
end
diff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.ex
index 35dd591dd..cebf2927f 100644
--- a/lib/plausible_web/router.ex
+++ b/lib/plausible_web/router.ex
@@ -233,14 +233,10 @@ defmodule PlausibleWeb.Router do
get "/", PageController, :index
- get "/billing/change-plan", BillingController, :change_plan_form
get "/billing/change-plan/preview/:plan_id", BillingController, :change_plan_preview
post "/billing/change-plan/:new_plan_id", BillingController, :change_plan
- get "/billing/upgrade", BillingController, :upgrade
get "/billing/choose-plan", BillingController, :choose_plan
get "/billing/upgrade-to-enterprise-plan", BillingController, :upgrade_to_enterprise_plan
- get "/billing/upgrade/enterprise/:plan_id", BillingController, :upgrade_enterprise_plan
- get "/billing/change-plan/enterprise/:plan_id", BillingController, :change_enterprise_plan
get "/billing/upgrade-success", BillingController, :upgrade_success
get "/billing/subscription/ping", BillingController, :ping_subscription
diff --git a/lib/plausible_web/templates/auth/user_settings.html.heex b/lib/plausible_web/templates/auth/user_settings.html.heex
index 516958bec..1cb2d5fd7 100644
--- a/lib/plausible_web/templates/auth/user_settings.html.heex
+++ b/lib/plausible_web/templates/auth/user_settings.html.heex
@@ -35,7 +35,6 @@
- Depending on which plan you choose, your card might be charged immediately and your
- next payment date could change. You can preview these changes before committing.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Monthly pageviews
-
-
- Price
-
-
-
-
- <%= for plan <- Plausible.Billing.Plans.growth_plans_for(@conn.assigns[:current_user]) do %>
- <%= render("_plan_option.html", plan: plan) %>
- <% end %>
-
-
- You've used <%= PlausibleWeb.AuthView.delimit_integer(@usage) %> billable pageviews in the last 30 days
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Monthly pageviews
-
-
- Price
-
-
-
-
- <%= for plan <- Plausible.Billing.Plans.growth_plans_for(@user) do %>
- <%= render("_plan_option.html", plan: plan) %>
- <% end %>
-
-
-
-
-
-
-
-
-
-
Due today:
-
+ VAT if applicable
-
-
-
-
-
-
-
-
- What happens if I go over my page views limit?
-
-
- You will never be charged extra for an occasional traffic spike. There are no surprise fees and your card will never be charged unexpectedly.
- If your page views exceed your plan for two consecutive months, we will contact you to upgrade to a higher plan for the following month. You will have two weeks to make a decision. You can decide to continue with a higher plan or to cancel your account at that point.
-
-
-<%= render("_paddle_script.html") %>
diff --git a/lib/plausible_web/templates/email/dashboard_locked.html.eex b/lib/plausible_web/templates/email/dashboard_locked.html.eex
index d6dc398f1..64d2dc944 100644
--- a/lib/plausible_web/templates/email/dashboard_locked.html.eex
+++ b/lib/plausible_web/templates/email/dashboard_locked.html.eex
@@ -7,7 +7,7 @@ During the last billing cycle (<%= PlausibleWeb.TextHelpers.format_date_range(@u
<%= if @suggested_plan == :enterprise do %>
Your usage exceeds our standard plans, so please reply back to this email for a tailored quote.
<% else %>
-<%= link("Click here to upgrade your subscription", to: plausible_url() <> Plausible.Billing.upgrade_route_for(@user)) %>. We recommend you upgrade to the <%= @suggested_plan.volume %>/mo plan. The new charge will be prorated to reflect the amount you have already paid and the time until your current subscription is supposed to expire.
+<%= link("Click here to upgrade your subscription", to: PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan)) %>. We recommend you upgrade to the <%= @suggested_plan.volume %>/mo plan. The new charge will be prorated to reflect the amount you have already paid and the time until your current subscription is supposed to expire.
<% end %>
Do you have questions or need help with anything? Just reply to this email. We're here to help!
diff --git a/lib/plausible_web/templates/email/over_limit.html.eex b/lib/plausible_web/templates/email/over_limit.html.eex
index af9feb273..3ac2dc440 100644
--- a/lib/plausible_web/templates/email/over_limit.html.eex
+++ b/lib/plausible_web/templates/email/over_limit.html.eex
@@ -9,7 +9,7 @@ During the last billing cycle (<%= PlausibleWeb.TextHelpers.format_date_range(@u
<%= if @suggested_plan == :enterprise do %>
Your usage exceeds our standard plans, so please reply back to this email for a tailored quote.
<% else %>
-<%= link("Click here to upgrade your subscription", to: plausible_url() <> Plausible.Billing.upgrade_route_for(@user)) %>. We recommend you upgrade to the <%= @suggested_plan.volume %>/mo plan. The new charge will be prorated to reflect the amount you have already paid and the time until your current subscription is supposed to expire.
+<%= link("Click here to upgrade your subscription", to: PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan)) %>. We recommend you upgrade to the <%= @suggested_plan.volume %>/mo plan. The new charge will be prorated to reflect the amount you have already paid and the time until your current subscription is supposed to expire.
<% end %>
Do you have questions or need help with anything? Just reply to this email. We're here to help!
diff --git a/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex b/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex
index cd1112910..32bebaab1 100644
--- a/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex
+++ b/lib/plausible_web/templates/email/trial_one_week_reminder.html.eex
@@ -2,6 +2,6 @@ Time flies! Your 30-day free trial of Plausible will end next week.
Over the last three weeks, We hope you got to experience the potential benefits of having website stats in an easy to use dashboard while respecting the privacy of your visitors, not annoying them with the cookie and privacy notices and still having a fast loading site.
-In order to continue receiving valuable website traffic insights at a glance, you’ll need to <%= link("upgrade your account", to: plausible_url() <> Plausible.Billing.upgrade_route_for(@user)) %>.
+In order to continue receiving valuable website traffic insights at a glance, you’ll need to <%= link("upgrade your account", to: PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan)) %>.
If you have any questions or feedback for us, feel free to reply to this email.
diff --git a/lib/plausible_web/templates/email/trial_over_email.html.eex b/lib/plausible_web/templates/email/trial_over_email.html.eex
index 41766f8bf..55a422fce 100644
--- a/lib/plausible_web/templates/email/trial_over_email.html.eex
+++ b/lib/plausible_web/templates/email/trial_over_email.html.eex
@@ -1,6 +1,6 @@
Your free Plausible trial has now expired. Upgrade your account to continue receiving valuable website traffic insights at a glance while respecting the privacy of your visitors and still having a fast loading site.
-<%= link("Upgrade now", to: plausible_url() <> Plausible.Billing.upgrade_route_for(@user)) %>
+<%= link("Upgrade now", to: PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan)) %>
We will keep recording stats for another month to give you time to upgrade.
diff --git a/lib/plausible_web/templates/email/trial_upgrade_email.html.eex b/lib/plausible_web/templates/email/trial_upgrade_email.html.eex
index 7d92bd872..e410e7a58 100644
--- a/lib/plausible_web/templates/email/trial_upgrade_email.html.eex
+++ b/lib/plausible_web/templates/email/trial_upgrade_email.html.eex
@@ -6,7 +6,7 @@ This is more than our standard plans, so please reply back to this email to get
<% else %>
Based on that we recommend you select a <%= @suggested_plan.volume %>/mo plan.
-<%= link("Upgrade now", to: plausible_url() <> Plausible.Billing.upgrade_route_for(@user)) %>
+<%= link("Upgrade now", to: PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan)) %>
Have a question, feedback or need some guidance? Just reply to this email to get in touch!
<% end %>
diff --git a/lib/plausible_web/templates/email/yearly_expiration_notification.html.eex b/lib/plausible_web/templates/email/yearly_expiration_notification.html.eex
index 2a85813f2..1f3a96b7f 100644
--- a/lib/plausible_web/templates/email/yearly_expiration_notification.html.eex
+++ b/lib/plausible_web/templates/email/yearly_expiration_notification.html.eex
@@ -1,6 +1,6 @@
Time flies! This is a reminder that your annual subscription for Plausible Analytics will expire on <%= @date %>.
-You need to <%= link("renew your subscription", to: plausible_url() <> Plausible.Billing.upgrade_route_for(@user)) %> if you want to continue using Plausible to count your website stats in a privacy-friendly way.
+You need to <%= link("renew your subscription", to: PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan)) %> if you want to continue using Plausible to count your website stats in a privacy-friendly way.
If you don't want to continue your subscription, there's no action required. You will lose access to the stats on <%= @date %>.
diff --git a/test/plausible_web/controllers/billing_controller_test.exs b/test/plausible_web/controllers/billing_controller_test.exs
index 79ddc5e6b..9108ca045 100644
--- a/test/plausible_web/controllers/billing_controller_test.exs
+++ b/test/plausible_web/controllers/billing_controller_test.exs
@@ -7,19 +7,6 @@ defmodule PlausibleWeb.BillingControllerTest do
@v4_growth_plan "857097"
@v4_business_plan "857105"
- describe "GET /upgrade" do
- setup [:create_user, :log_in]
-
- test "redirects user to enteprise plan page if they are configured with one", %{
- conn: conn,
- user: user
- } do
- insert(:enterprise_plan, user: user)
- conn = get(conn, Routes.billing_path(conn, :upgrade))
- assert redirected_to(conn) == Routes.billing_path(conn, :upgrade_to_enterprise_plan)
- end
- end
-
describe "GET /choose-plan" do
setup [:create_user, :log_in]
@@ -31,24 +18,6 @@ defmodule PlausibleWeb.BillingControllerTest do
end
end
- describe "GET /upgrade/enterprise/:plan_id (deprecated)" do
- setup [:create_user, :log_in]
-
- test "redirects to the new :upgrade_to_enterprise_plan action", %{conn: conn} do
- conn = get(conn, Routes.billing_path(conn, :upgrade_enterprise_plan, "123"))
- assert redirected_to(conn) == Routes.billing_path(conn, :upgrade_to_enterprise_plan)
- end
- end
-
- describe "GET /change-plan/enterprise/:plan_id (deprecated)" do
- setup [:create_user, :log_in]
-
- test "redirects to the new :upgrade_to_enterprise_plan action", %{conn: conn} do
- conn = get(conn, Routes.billing_path(conn, :change_enterprise_plan, "123"))
- assert redirected_to(conn) == Routes.billing_path(conn, :upgrade_to_enterprise_plan)
- end
- end
-
describe "POST /change-plan" do
setup [:create_user, :log_in]
diff --git a/test/plausible_web/email_test.exs b/test/plausible_web/email_test.exs
index 467f0cab2..8cee8b0bc 100644
--- a/test/plausible_web/email_test.exs
+++ b/test/plausible_web/email_test.exs
@@ -141,6 +141,10 @@ defmodule PlausibleWeb.EmailTest do
"cycle before that (#{PlausibleWeb.TextHelpers.format_date_range(penultimate_cycle)}), your account used 12,300 billable pageviews"
assert html_body =~ "/billing/choose-plan\">Click here to upgrade your subscription"
+
+ assert html_body =~
+ PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan)
+
assert html_body =~ "/settings\">account settings"
end
@@ -187,6 +191,10 @@ defmodule PlausibleWeb.EmailTest do
"cycle before that (#{PlausibleWeb.TextHelpers.format_date_range(penultimate_cycle)}), the usage was 12,300 billable pageviews"
assert html_body =~ "/billing/choose-plan\">Click here to upgrade your subscription"
+
+ assert html_body =~
+ PlausibleWeb.Router.Helpers.billing_url(PlausibleWeb.Endpoint, :choose_plan)
+
assert html_body =~ "/settings\">account settings"
end
diff --git a/test/plausible_web/plugins/api/controllers/custom_props_test.exs b/test/plausible_web/plugins/api/controllers/custom_props_test.exs
index bca39d0b3..801c5f8e6 100644
--- a/test/plausible_web/plugins/api/controllers/custom_props_test.exs
+++ b/test/plausible_web/plugins/api/controllers/custom_props_test.exs
@@ -42,7 +42,6 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest do
conn: conn
} do
site = Plausible.Repo.preload(site, :owner)
- FunWithFlags.enable(:business_tier, for_actor: site.owner)
insert(:growth_subscription, user: site.owner)
url = Routes.custom_props_url(base_uri(), :enable)
@@ -67,7 +66,6 @@ defmodule PlausibleWeb.Plugins.API.Controllers.CustomPropsTest do
conn: conn
} do
site = Plausible.Repo.preload(site, :owner)
- FunWithFlags.enable(:business_tier, for_actor: site.owner)
insert(:growth_subscription, user: site.owner)
url = Routes.custom_props_url(base_uri(), :enable)
diff --git a/test/plausible_web/plugins/api/controllers/goals_test.exs b/test/plausible_web/plugins/api/controllers/goals_test.exs
index fd6e8beb3..8b6390db2 100644
--- a/test/plausible_web/plugins/api/controllers/goals_test.exs
+++ b/test/plausible_web/plugins/api/controllers/goals_test.exs
@@ -53,7 +53,6 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
conn: conn
} do
site = Plausible.Repo.preload(site, :owner)
- FunWithFlags.enable(:business_tier, for_actor: site.owner)
insert(:growth_subscription, user: site.owner)
url = Routes.goals_url(base_uri(), :create)
@@ -80,7 +79,6 @@ defmodule PlausibleWeb.Plugins.API.Controllers.GoalsTest do
conn: conn
} do
site = Plausible.Repo.preload(site, :owner)
- FunWithFlags.enable(:business_tier, for_actor: site.owner)
insert(:growth_subscription, user: site.owner)
url = Routes.goals_url(base_uri(), :create)
diff --git a/test/test_helper.exs b/test/test_helper.exs
index ed8c80428..30f0ebbd5 100644
--- a/test/test_helper.exs
+++ b/test/test_helper.exs
@@ -1,7 +1,6 @@
{:ok, _} = Application.ensure_all_started(:ex_machina)
Mox.defmock(Plausible.HTTPClient.Mock, for: Plausible.HTTPClient.Interface)
Application.ensure_all_started(:double)
-FunWithFlags.enable(:business_tier)
FunWithFlags.enable(:window_time_on_page)
Ecto.Adapters.SQL.Sandbox.mode(Plausible.Repo, :manual)