diff --git a/lib/plausible_web/controllers/billing_controller.ex b/lib/plausible_web/controllers/billing_controller.ex index 3ce1ea12838b32b75a74342b784fea6624a00fd2..4f31637d10502a0951014b9a8d5afbab64c2d295 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 support@plausible.io" + 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 }