fix(billing): checkout guard, admin panel case - #6641
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryHigh Risk Overview Pending payment guard blocks a new checkout when the reference already has an Stripe adapter guard now refuses updates that rebind an existing local subscription row to a different Enterprise provisioning on correlated issuance sweeps the owner’s attachable personal workspaces into the new org (with locks, identity lock, stable workspace-set check, cache invalidation), and retries if the workspace set changes mid-reconciliation. Diagnostics: subscription/reference mismatch errors mention the bound reference explicitly. Reviewed by Cursor Bugbot for commit 89877b4. Configure here. |
Greptile SummaryThe PR adds database-backed checkout admission fencing and bound-incomplete-subscription checks, while tightening Stripe subscription binding and Enterprise workspace reconciliation.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously reported concurrent checkout race is addressed by an atomic database claim keyed by billing reference, with claim-token-fenced release preventing stale requests from releasing newer claims.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/auth/auth.ts | Wraps subscription upgrades in a database-backed checkout-admission claim spanning authorization and Stripe Checkout creation. |
| apps/sim/lib/billing/checkout-admission.ts | Adds reference resolution and short-lived, token-fenced database leases that serialize checkout creation. |
| apps/sim/lib/billing/authorization.ts | Rejects personal and organization checkouts while a bound incomplete Stripe subscription remains pending. |
| apps/sim/lib/auth/stripe-adapter-guard.ts | Prevents existing local subscription rows from being rebound to a different Stripe subscription ID. |
| apps/sim/lib/billing/webhooks/enterprise.ts | Reconciles eligible Enterprise-owner workspaces into the organization under workspace, organization, and billing-identity locks. |
Sequence Diagram
sequenceDiagram
participant Client
participant Auth as Better Auth hooks
participant Lease as Checkout admission DB
participant Stripe as Stripe plugin
participant DB as Subscription DB
Client->>Auth: POST /subscription/upgrade
Auth->>Lease: Atomically claim billing reference
alt Claim already held
Lease-->>Auth: Conflict
Auth-->>Client: Checkout already starting
else Claim acquired
Auth->>DB: Check bound incomplete subscription
Auth->>Stripe: Prepare local row and create Checkout
Stripe-->>Auth: Checkout result
Auth->>Lease: Release with fencing token
Auth-->>Client: Checkout response
end
Reviews (3): Last reviewed commit: "fix(billing): release checkout admission..." | Re-trigger Greptile
cad7f04 to
485d1ab
Compare
|
@cursor review |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 89877b4. Configure here.
Summary
Prevent Stripe webhooks from rebinding an existing local row to a different Stripe subscription.
Block duplicate checkouts while a bound incomplete payment is pending, while keeping abandoned checkouts retryable.
Sweep an Enterprise owner’s eligible personal workspaces into the new organization, including free users.
Improve subscription/reference mismatch errors for easier diagnosis.
Type of Change
Testing
Tested manually
Checklist