Skip to content

fix(billing): retain checkout references for superseded Xendit sessions - #30

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-identification-cbf6
Draft

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-identification-cbf6

Conversation

@cursor

@cursor cursor Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Bug and impact

When a workspace started a second Plus checkout, beginCheckout overwrote subscriptions.provider_reference. If the user completed payment on an older Xendit session, the webhook carried that session's reference_id, findPaymentTargetByProviderReference returned null (404), and Plus was never activated despite a successful charge.

Root cause

Only the latest checkout reference was stored on the subscription row; superseded references were discarded.

Fix

  • Add billing_checkout_sessions with one immutable row per checkout reference_id.
  • Record a session row on every beginCheckout.
  • Resolve webhook targets from the session registry first, then fall back to subscriptions.provider_reference for legacy rows.
  • Backfill existing subscription references in the migration.

Validation

  • pnpm exec prisma generate in packages/db
  • pnpm test -- platform.test.ts in packages/db (68 passed)
Open in Web View Automation 

Starting a new checkout overwrote subscriptions.provider_reference, so a
payment webhook for an older session returned 404 and never activated Plus.

Persist every reference_id in billing_checkout_sessions and resolve webhooks
against that registry before falling back to the subscription row.

Co-Authored-By: Cursor <cursoragent@cursor.com>

Co-authored-by: drferdiiskandar <drferdiiskandar@sentrahai.com>
@vercel

vercel Bot commented Oct 9, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
sentrabot-site Skipped Skipped Oct 9, 2026 11:14am UTC

Request Review

This branch was previously deployed

1 inactive deployment
Preview — 93e4779b Deployed Oct 9, 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