Skip to content

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

Show better error message when changing plans fails

Uku Tahte1bb4368460e
diff --git a/lib/plausible_web/controllers/billing_controller.ex b/lib/plausible_web/controllers/billing_controller.ex
index 3ce1ea1283..4f31637d10 100644
--- a/lib/plausible_web/controllers/billing_controller.ex
+++ b/lib/plausible_web/controllers/billing_controller.ex
@@ -47,9 +47,23 @@ defmodule PlausibleWeb.BillingController do
|> redirect(to: "/settings")
{:error, e} ->
+ # https://developer.paddle.com/api-reference/intro/api-error-codes
+ msg =
+ case e do
+ %{"code" => 147} ->
+ "We were unable to charge your card. Make sure your payment details are up to date and try again."
+
+ %{"message" => msg} when not is_nil(msg) ->
+ msg
+
+ _ ->
+ "Something went wrong. Please try again or contact support at [email protected]"
+ end
+
Sentry.capture_message("Error changing plans",
extra: %{
errors: inspect(e),
+ message: msg,
new_plan_id: new_plan_id,
user_id: conn.assigns[:current_user].id
}