Skip to content

Stop active subscribers from creating duplicate Polar checkouts - #48

Merged
engmsaleh merged 1 commit into
mainfrom
fix/checkout-state-telemetry
Aug 2, 2026
Merged

Stop active subscribers from creating duplicate Polar checkouts#48
engmsaleh merged 1 commit into
mainfrom
fix/checkout-state-telemetry

Conversation

@engmsaleh

Copy link
Copy Markdown
Collaborator

Outcome:

  • refreshes entitlement immediately before checkout creation
  • routes active subscribers to the customer portal
  • ignores concurrent checkout requests in the Mac app
  • rejects active subscribers at the Worker boundary for older clients
  • correlates checkout creation, browser opening, failures, expiration, and provider states
  • documents the unique-person/session reporting contract

Evidence:

  • Polar showed one paid subscriber creating 15 later expired checkout sessions
  • Worker production dry-run compiles successfully
  • changed Swift and regression tests pass syntax validation
  • full terminal xcodebuild was not run because repository policy explicitly forbids it

Deployment note:

Enable Polar webhook events checkout.updated and checkout.expired after the Worker deployment so provider outcome events reach PostHog.

Repeated Polar sessions came from one active subscriber because checkout intent was recorded before entitlement verification and concurrent clicks were not guarded. Refresh entitlement before purchase creation, route active subscribers to their portal, enforce the same rule at the Worker boundary for older clients, and correlate checkout outcomes with stable attempt and provider IDs.

Constraint: Existing macOS releases can call the Worker without the new client guard, so server enforcement is required.

Constraint: Polar expiration and provider-status analytics require checkout.updated and checkout.expired webhook subscriptions.

Rejected: Fix reporting only | Polar confirmed real duplicate checkout records, so deduplication alone would leave customer and billing risk.

Confidence: high

Scope-risk: moderate

Reversibility: clean

Directive: Keep active-subscription enforcement in the Worker even if client checkout UI changes.

Tested: Wrangler production dry-run compile; Swift syntax parse; checkout-decision regression tests added; git diff --check

Not-tested: Full Xcode test target because repository policy forbids terminal xcodebuild; live Polar webhook delivery until deployment and event subscription.
@vercel

vercel Bot commented Aug 2, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
skilly-studio Ready Ready Preview Aug 2, 2026 6:14pm

Request Review

@engmsaleh
engmsaleh merged commit 1cc3cd8 into main Aug 2, 2026
10 checks passed
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