Add subscription status middleware to gate /api/generate behind active Stripe subscription #650

Open
opened 2026-04-11 08:52:04 -04:00 by pook · 0 comments
Owner

Create requireSubscription middleware that: (1) runs after authMiddleware, (2) queries stripe.subscriptions.list({ customer: user.stripeCustomerId, status: 'active' }), (3) if no active subscription found, returns 402 JSON { error: 'Active subscription required', upgradeUrl: '/api/billing/checkout' }, (4) attaches subscription to req for downstream use. Apply to POST /api/generate route. Without this, the billing checkout has no enforcement — users can generate documents without paying.


Generated by CEO Planner (priority: 3)

Create requireSubscription middleware that: (1) runs after authMiddleware, (2) queries stripe.subscriptions.list({ customer: user.stripeCustomerId, status: 'active' }), (3) if no active subscription found, returns 402 JSON { error: 'Active subscription required', upgradeUrl: '/api/billing/checkout' }, (4) attaches subscription to req for downstream use. Apply to POST /api/generate route. Without this, the billing checkout has no enforcement — users can generate documents without paying. --- *Generated by CEO Planner (priority: 3)*
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#650
No description provided.