Repository navigation
fix(billing): block tracking + features for orgs without active subscription - #56
Merged
Merged
Conversation
…ription Three places on the aeo-server fell back to starter plan limits whenever an org's Stripe subscription was not active. That meant any signup who completed onboarding and closed the Stripe checkout tab — leaving the org at plan='free' subscription_status='incomplete' — silently kept running on-demand tracking, daily monitoring cron, and gated feature calls, with Cloro and AI provider spend still landing on us. The intended rule is: only orgs with subscription_status of 'active' or 'trialing' (which Stripe sets while a paid plan is in its free-trial period) may use billed features. Everything else (incomplete, canceled, past_due, unpaid) is blocked. Centralizes the check as isSubscriptionActive() in config/plans.js and applies it in three spots: - routes/tracking.js POST /check — returns 402 with a "subscribe to continue" message instead of falling back to starter limits - server.js runDailyTracking() cron — skips brands whose org has no active subscription; previously these brands silently consumed daily jobs - lib/plan-guard.js resolveOrgPlan() — throws PlanLimitError(402) on feature checks (volume fetch, content generation, etc.) Self-hosted instances are unaffected: isSubscriptionActive() short- circuits to true when IS_CLOUD !== 'true'. Note on Next.js side: the (dashboard) layout already redirects when subscription_status is not active/trialing, so the gap was entirely on the aeo-server endpoints / cron that don't go through that layout.
Merged
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
What changes
Centralizes the check as `isSubscriptionActive(status)` in `server/src/config/plans.js` and applies it in three spots:
Self-hosted instances are unaffected — `isSubscriptionActive()` short-circuits to `true` when `IS_CLOUD !== 'true'`.
What this does NOT change
The Next.js `(dashboard)` layout already redirects when `subscription_status` is not active/trialing. The gap was entirely on the aeo-server endpoints/cron that don't go through that layout — they were the silent leak. UI behaviour stays the same; users hitting a blocked endpoint will see a "subscribe to continue" message instead of phantom progress.
Existing 6 unsubscribed orgs
There are 6 orgs at `plan='free'` / `subscription_status='incomplete'` today (real prospect signups, including one major TR retail brand). After this lands they lose tracking access on their next attempt. The "soft cut + manual outreach" path is intentional — they're high-value prospects, the maintainer will email them to push through Stripe checkout before merge.
Test plan