Skip to content

Commit e5f4c59

Browse files
Sai Sridhar Tarraclaude
authored andcommitted
Fix: show real Stripe error in toast + add /billing/stripe-check endpoint
billing/index.tsx: - Toast now shows actual backend detail message instead of hardcoded string - Falls back to err.message then generic text if no detail - duration: 6000ms so user can read the full error - console.error logs the full error for debugging billing.py: - Add GET /api/billing/stripe-check endpoint - Returns which env vars are set (secret key masked as bool, price IDs shown) - Helps diagnose missing Render config without checking the dashboard Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1280d63 commit e5f4c59

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

backend/routes/billing.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ async def billing_status(current_user: Annotated[dict, Depends(get_current_user)
3333
return await get_subscription_status(user_id=current_user["id"])
3434

3535

36+
@router.get("/stripe-check")
37+
async def stripe_config_check(current_user: Annotated[dict, Depends(get_current_user)]):
38+
"""Return which Stripe env vars are configured (values masked)."""
39+
from config import settings
40+
return {
41+
"STRIPE_SECRET_KEY": bool(settings.STRIPE_SECRET_KEY),
42+
"STRIPE_WEBHOOK_SECRET": bool(settings.STRIPE_WEBHOOK_SECRET),
43+
"STRIPE_PRO_PRICE_ID": settings.pro_monthly_price_id or "NOT SET",
44+
"STRIPE_AGENCY_PRICE_ID": settings.agency_monthly_price_id or "NOT SET",
45+
"FRONTEND_URL": settings.FRONTEND_URL or "NOT SET",
46+
}
47+
48+
3649
@router.post("/checkout")
3750
async def create_checkout(
3851
body: CheckoutRequest,

frontend/pages/billing/index.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,11 @@ export default function BillingPage() {
116116
const { checkout_url } = await billingApi.createCheckoutSession(planId, 'monthly', priceId);
117117
window.location.href = checkout_url;
118118
} catch (err: unknown) {
119-
const msg =
119+
const detail =
120120
(err as { response?: { data?: { detail?: string } } })?.response?.data?.detail;
121-
toast.error(
122-
msg === 'No valid price_id or plan_id provided.'
123-
? 'Stripe is not configured. Set STRIPE_PRO_PRICE_ID / STRIPE_AGENCY_PRICE_ID in your backend .env.'
124-
: 'Failed to start checkout. Please try again.'
125-
);
121+
const msg = detail || (err instanceof Error ? err.message : null);
122+
toast.error(msg || 'Failed to start checkout. Please try again.', { duration: 6000 });
123+
console.error('[checkout]', err);
126124
setLoadingPlan(null);
127125
}
128126
};

0 commit comments

Comments
 (0)