Skip to content

fix(billing): refuse self-serve Enterprise checkout with a client error - #10469

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/enterprise-self-serve-checkout-500
Nov 27, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
fix/enterprise-self-serve-checkout-500

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Self-serve checkout (/subscription/upgrade) now refuses plan: 'enterprise' with a 400 before taking the checkout admission claim
  • Enterprise is issued by the team with its own Stripe price and metadata. The Stripe plugin's placeholder price can never check out, and its write of enterprise onto a pending subscription row failed the check_enterprise_metadata constraint, so the caller got a 500

Type of Change

  • Bug fix

Testing

  • lib/billing/authorization.test.ts: Enterprise refused with a 400, Pro and Team admitted. The refusal case fails with the guard removed
  • biome, check:api-validation:strict, check:test-patterns

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Enterprise is issued by the team with its own Stripe price and metadata. A self-serve upgrade
naming it wrote the plan onto a pending subscription row, which the Enterprise metadata
constraint rejected, and the caller got a 500. The checkout hook now refuses it with a 400
before taking the admission claim.
@vercel

vercel Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 27, 2026 10:59pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5 · Normalize the Enterprise plan name before merging so changing its case cannot bypass the new refusal.RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change is limited to the self-serve subscription checkout path.

Normalize the Enterprise plan name before merging so changing its case cannot bypass the new refusal.

Findings

  1. P1 Mixed-case Enterprise bypasses refusal ▶

Summary

Adds an early Enterprise refusal to /subscription/upgrade and tests the new helper.

  • Enterprise plan requests now get a clear error before checkout begins.

Reviews (2) · Last reviewed commit: "fix(billing): refuse self-serve Enterpri..." · Reviewed by Greptile

@waleedlatif1
waleedlatif1 merged commit 055c1a6 into staging Nov 27, 2026
83 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/enterprise-self-serve-checkout-500 branch November 27, 2026 23:06
@waleedlatif1 waleedlatif1 changed the title fix(billing): refuse self-serve Enterprise checkout with a client error fix(billing): tighten self-serve checkout and Enterprise reconciliation Nov 28, 2026
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@waleedlatif1 waleedlatif1 changed the title fix(billing): tighten self-serve checkout and Enterprise reconciliation fix(billing): refuse self-serve Enterprise checkout with a client error Nov 28, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

* and its write to a pending subscription row fails the Enterprise metadata constraint.
*/
export function assertSelfServeCheckoutPlan(plan: unknown): void {
if (typeof plan !== 'string' || !isEnterprise(plan)) return

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Mixed-case Enterprise bypasses refusal

assertSelfServeCheckoutPlan only rejects lowercase enterprise because isEnterprise uses exact equality. A personal checkout with plan: 'Enterprise' or 'ENTERPRISE' passes this guard, but the Stripe plugin accepts either spelling. Enterprise remains in getPlans(), so the pending subscription write fails the database's Enterprise metadata check and returns a server error instead of the intended 400.

Normalize the name before checking it and add mixed-case regression tests.

Suggested change
if (typeof plan !== 'string' || !isEnterprise(plan)) return
if (typeof plan !== 'string' || !isEnterprise(plan.trim().toLowerCase())) return

This branch was previously deployed

1 inactive deployment
Preview — 4f2bd34e Deployed Nov 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant