Skip to content

feat(skill-api): let epic-web skip Course Builder checkout sessions - #1919

Merged
Creeland merged 3 commits into
mainfrom
creeland/epw-skip-course-builder-sessions
Nov 18, 2026
Merged

Creeland merged 3 commits into
mainfrom
creeland/epw-skip-course-builder-sessions

Conversation

@Creeland

Copy link
Copy Markdown
Contributor

What

processStripeWebhook answers 200 not handled: course-builder session without recording anything for a checkout.session.completed whose session carries metadata.cbPricingContract. It does this only when SKIP_COURSE_BUILDER_CHECKOUT_SESSIONS=true. Only apps/epic-web/.env.production sets that variable. Epic React and Testing JavaScript are unchanged.

This is the legacy half of the origin rule. The Course Builder half is badass-courses/course-builder#1210: ignoreCheckoutSessionsWithoutPricingContract makes the new app skip any payment session without the marker.

Why

Epic Web is moving to the Course Builder app with no checkout freeze. For a while both apps sell, and both Stripe endpoints are live on the same account:

  • Both apps resolve the same Stripe catalog. Every Epic Web Stripe product and price exists in both apps' tables. Legacy routes on metadata.siteName, and Course Builder stamps the same epic-web. Without this filter, legacy would record a Course Builder sale as a second Purchase for the same charge. It would also send the legacy purchase email and run the post-purchase automations (Discord, bundles, ConvertKit).
  • The legacy endpoint can't simply be disabled. It is also the only path for Epic React and Testing JavaScript sales: determineEventProcessor forwards their events by siteName. So legacy has to stay on and skip the other app's sessions.

Course Builder stamps cbPricingContract on every checkout session it creates. skill-api never sets it, so the marker identifies the creator.

Where the skip sits

  • Direct endpoint (/api/skill/webhook/stripe): the signature is verified, then routing by siteName sends epic-web (or a missing siteName) to self → processStripeWebhook → skip.
  • stripe-internal (forwarded from this endpoint to ER/TJS deployments): receiveInternalStripeWebhooks → processStripeWebhook, so the same check applies on any deployment that sets the variable. Course Builder sessions are never forwarded, because their siteName is epic-web.
  • recordNewPurchase has no other caller. The thanks and welcome pages only read.
  • STRIPE_WEBHOOK_RECEIVED_EVENT still goes to Inngest before routing, as it does for every event. Of its listeners, only stripe-invoice-paid writes anything, and it acts on invoice.* events, not checkout sessions (see "Not covered").
  • Refunds and disputes need no rule. updatePurchaseStatusForCharge does nothing for a charge legacy doesn't hold, so a Course Builder charge's charge.refunded is a no-op here.

How it was tested

  • New process-stripe-webhook.test.ts (jest, 9 cases):
    • The predicate: unset, a non-"true" value, a marked session, an unmarked session, an empty marker, and null or missing metadata.
    • processStripeWebhook with the variable set: a marked session is skipped and recordNewPurchase is never called; an unmarked (legacy) session still records.
    • With the variable unset, a marked session still records (inert by default).
    • Both entry points skip: receiveStripeWebhooks with a verified event, and receiveInternalStripeWebhooks.
  • pnpm --filter @skillrecordings/skill-api test: 2 suites, 10 tests pass.
  • tsc --noEmit is clean for packages/skill-api and apps/epic-web, after turbo run generate build of their dependencies.
  • Not tested end to end. No Stripe event has been sent to a deployment with this change. That test belongs to the cutover plan: in Stripe test mode with both endpoints live, one legacy session and one Course Builder session should each be recorded exactly once.

Inert until a Course Builder session exists

No checkout session on this account carries cbPricingContract until the new Epic Web app takes a sale. Today no Stripe endpoint exists for that app, so this changes nothing on deploy. It should be deployed before the new app's endpoint is added.

Not covered: one-off invoices

Since #1916, this app fulfils paid one-off invoices (stripe-invoice-paid). The Course Builder app has its own invoice fulfilment (core's handler on main, and badass-courses/course-builder#1199). Invoices are created by hand in the Stripe dashboard, so they carry no app marker and this rule can't apply to them. With both endpoints subscribed to invoice.payment_succeeded, one invoice would be fulfilled by both apps. Which app owns invoice fulfilment during the overlap is a separate decision, tracked in the cutover plan. This PR does not change invoice handling.

Do not merge without review.

🤖 Generated with Claude Code

The Course Builder app that replaces legacy Epic Web sells the same Stripe
products on the same account and records its own checkout sessions through
its own webhook endpoint. With both endpoints live, legacy would record
those sessions too: a second Purchase for one charge, plus the legacy
purchase email and post-purchase automations.

processStripeWebhook now answers 200 without recording a
checkout.session.completed whose session carries metadata.cbPricingContract
(stamped by Course Builder on every session it creates, never by skill-api),
when SKIP_COURSE_BUILDER_CHECKOUT_SESSIONS=true. Both the direct Stripe
endpoint and the stripe-internal forwarded endpoint go through it. Only
apps/epic-web sets the variable; Epic React and Testing JavaScript are
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
badass-turbo Ready Ready Preview Nov 18, 2026 9:11pm UTC
epic-react-v1 Ready Ready Preview Nov 18, 2026 9:11pm UTC
epic-web Ready Ready Preview Nov 18, 2026 9:11pm UTC
testing-javascript Ready Ready Preview Nov 18, 2026 9:11pm UTC
total-typescript-turbo Ready Ready Preview Nov 18, 2026 9:11pm UTC

Creeland and others added 2 commits November 18, 2026 15:06
…review

- charge.refunded for a Course Builder charge legacy has no purchase for returns 200 instead of 400, so Stripe does not retry it for days on the shared router endpoint. A charge legacy does have a purchase for is still updated; an unknown legacy charge still throws.
- SKIP_COURSE_BUILDER_CHECKOUT_SESSIONS is trimmed and case-insensitive, so TRUE or a trailing space no longer turns the filter off silently.
- Skip logs carry the session or charge id, event id and pricing contract marker.
- Tests: env parsing, refunds, and Epic React / Testing JavaScript forwarding with the switch on (9 -> 17).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

This branch was successfully deployed

5 active deployments
Preview – epic-web — 288c03c2 Deployed Nov 18, 2026 by vercel[bot]
Preview – epic-react-v1 — 288c03c2 Deployed Nov 18, 2026 by vercel[bot]
Preview – total-typescript-turbo — 288c03c2 Deployed Nov 18, 2026 by vercel[bot]
Preview – testing-javascript — 288c03c2 Deployed Nov 18, 2026 by vercel[bot]
Preview – badass-turbo — 288c03c2 Deployed Nov 18, 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