diff --git a/web/src/beanflows/billing/routes.py b/web/src/beanflows/billing/routes.py index 3a6aadb..e9cb1f3 100644 --- a/web/src/beanflows/billing/routes.py +++ b/web/src/beanflows/billing/routes.py @@ -201,14 +201,18 @@ async def manage(): await flash("No active subscription found.", "error") return redirect(url_for("dashboard.settings")) - async with httpx.AsyncClient() as client: - response = await client.get( - f"https://api.paddle.com/subscriptions/{sub['provider_subscription_id']}", - headers={"Authorization": f"Bearer {config.PADDLE_API_KEY}"}, - ) - response.raise_for_status() + try: + async with httpx.AsyncClient() as client: + response = await client.get( + f"https://api.paddle.com/subscriptions/{sub['provider_subscription_id']}", + headers={"Authorization": f"Bearer {config.PADDLE_API_KEY}"}, + ) + response.raise_for_status() + portal_url = response.json()["data"]["management_urls"]["update_payment_method"] + except Exception: + await flash("Could not reach the billing portal. Please try again or contact support.", "error") + return redirect(url_for("dashboard.settings")) - portal_url = response.json()["data"]["management_urls"]["update_payment_method"] return redirect(portal_url) diff --git a/web/src/beanflows/dashboard/templates/settings.html b/web/src/beanflows/dashboard/templates/settings.html index 57d5f6f..eb2fda4 100644 --- a/web/src/beanflows/dashboard/templates/settings.html +++ b/web/src/beanflows/dashboard/templates/settings.html @@ -111,19 +111,7 @@ -