Add Stripe API error handling to billing portal endpoint #1307

Open
opened 2026-04-13 12:43:26 -04:00 by pook · 0 comments
Owner

PR #782 adds POST /api/billing/portal but likely only handles the happy path. Add error handling for common Stripe API failures: 1) 401 Unauthorized (invalid API key) → return 503 with { error: 'Billing service temporarily unavailable' }, 2) 429 Rate Limited → return 429 with retry-after hint, 3) 500/502/503 Stripe server errors → return 502 with { error: 'Payment provider error, please try again' }. Wrap the stripe.billingPortal.sessions.create() call in a try/catch that maps Stripe errors to user-safe responses. Never expose raw Stripe error messages to the client. Add 3 test cases covering each error scenario.


Generated by CEO Planner (priority: 2)

PR #782 adds POST /api/billing/portal but likely only handles the happy path. Add error handling for common Stripe API failures: 1) 401 Unauthorized (invalid API key) → return 503 with `{ error: 'Billing service temporarily unavailable' }`, 2) 429 Rate Limited → return 429 with retry-after hint, 3) 500/502/503 Stripe server errors → return 502 with `{ error: 'Payment provider error, please try again' }`. Wrap the stripe.billingPortal.sessions.create() call in a try/catch that maps Stripe errors to user-safe responses. Never expose raw Stripe error messages to the client. Add 3 test cases covering each error scenario. --- *Generated by CEO Planner (priority: 2)*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot#1307
No description provided.