Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Make sure upgrading to unlisted plans works OK

Uku Tahtd1ef27ec9ce2
diff --git a/lib/plausible/billing/plans.ex b/lib/plausible/billing/plans.ex
index 619c2a9a2e..714b29477c 100644
--- a/lib/plausible/billing/plans.ex
+++ b/lib/plausible/billing/plans.ex
@@ -72,7 +72,7 @@ defmodule Plausible.Billing.Plans do
}
]
- @yearly_plans_v1 [
+ @unlisted_plans_v1 [
%{limit: 150_000_000, yearly_product_id: "648089", yearly_cost: "$4800"}
]
@@ -85,7 +85,7 @@ defmodule Plausible.Billing.Plans do
end
def for_product_id(product_id) do
- Enum.find(@plans_v1, fn plan ->
+ Enum.find(@plans_v1 ++ @unlisted_plans_v1, fn plan ->
product_id in [plan[:monthly_product_id], plan[:yearly_product_id]]
end)
end
diff --git a/lib/plausible_web/controllers/billing_controller.ex b/lib/plausible_web/controllers/billing_controller.ex
index 4f31637d10..52660ff2ba 100644
--- a/lib/plausible_web/controllers/billing_controller.ex
+++ b/lib/plausible_web/controllers/billing_controller.ex
@@ -94,6 +94,9 @@ defmodule PlausibleWeb.BillingController do
plan = Plausible.Billing.Plans.for_product_id(plan_id)
if plan do
+ cycle = if plan[:monthly_product_id] == plan_id, do: "monthly", else: "yearly"
+ cost = if cycle == "monthly", do: plan[:monthly_cost], else: plan[:yearly_cost]
+ plan = Map.merge(plan, %{cycle: cycle, cost: cost, product_id: plan_id})
usage = Plausible.Billing.usage(conn.assigns[:current_user])
render(conn, "upgrade_to_plan.html",