Repository navigation
feat(billing): add to my invoice — contract orgs upgrade at their AI limit - #7761
Merged
Merged
Conversation
added 2 commits
October 6, 2026 19:21
…limit AI_PLAN_INVOICE_UPGRADE moves an org flagged invoice_upgrade onto Starter or Business with no Stripe, once its usage bar is exhausted. Fails closed: plans on, flag read fresh from the gateway, bar exhausted, no Stripe subscription bound, not the current plan. Records an audit note on the gateway plan row and emits plan_invoice_upgrade for finance. The plan catalog shows a flagged custom org at its limit the Starter and Business cards with both Stripe and 'Add to my invoice'.
…limit Matches the server: the button needs invoice_upgrade AND an exhausted bar, so a flagged org below its limit is never offered an upgrade it would be refused.
pedrofrxncx
enabled auto-merge (squash)
October 6, 2026 22:41
decocms Bot
pushed a commit
that referenced
this pull request
Oct 6, 2026
PR: #7761 feat(billing): add to my invoice — contract orgs upgrade at their AI limit Bump type: minor - decocms (apps/api/package.json): 4.442.0 -> 4.443.0 - @decocms/native (apps/native/package.json): 4.442.0 -> 4.443.0 - @decocms/shared (packages/shared/package.json): 0.135.0 -> 0.136.0 Deploy-Scope: both
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.
"You've reached your AI usage limit" for our contract customers: Stripe, or "Adicionar à minha fatura". The gateway side is in decocms/ai-gateway#41.
What it does
deco.cx customers are placed on
customwith a small hidden allowance and pay by boleto. Staff can flag one withinvoice_upgradein the org-admin UI. Once its bar is exhausted, the plan catalog shows Starter and Business, each with:AI_PLAN_INVOICE_UPGRADESame permission as
AI_PLAN_SET(ai-providers:manage). It grants a paid plan without payment, so it fails closed instead of usingrequiresFeature, which fails open. It requires all of:features.invoice_upgrade === trueexhausted; an unreadable usage refusesIt then places the plan via the gateway admin route with an audit note ("invoice upgrade by at — bill on next invoice"), clears the plan cache fleet-wide, and emits the PostHog event
plan_invoice_upgrade(plan_id,previous_plan_id,org_slug,org_name). Finance needs a PostHog → Slack alert on that event, since neither repo has a Slack integration.UI
STUDIO_PLANS_ENABLEDis on.Tests
plan-change.test.ts: 8 tests for the guard. The ai-providers suite passes 36/36.tscfor api, web and shared passes; oxlint and knip are clean.Summary by cubic
Allows deco contract orgs to upgrade to a paid plan at their AI limit and get billed on their next deco invoice instead of going through Stripe.
AI_PLAN_INVOICE_UPGRADE, which fails closed: it requires plans enabled,invoice_upgradeset totrueand read fresh from the gateway, the usage bar exhausted, no bound Stripe subscription, and a target plan the org is not already on.customorg only once its usage is exhausted, with both Stripe and "Add to my invoice" buttons on the Starter and Business cards. Flagged orgs already on self-serve plans without a Stripe subscription get the invoice button on the other plans too.plan_invoice_upgradeon PostHog — finance needs a PostHog → Slack alert on that event.Written for commit 49d558d. Summary will update on new commits.