Repository navigation
feat(skill-api): let epic-web skip Course Builder checkout sessions - #1919
Merged
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…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>
…rse-builder-sessions
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
processStripeWebhookanswers200 not handled: course-builder sessionwithout recording anything for acheckout.session.completedwhose session carriesmetadata.cbPricingContract. It does this only whenSKIP_COURSE_BUILDER_CHECKOUT_SESSIONS=true. Onlyapps/epic-web/.env.productionsets 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:
ignoreCheckoutSessionsWithoutPricingContractmakes 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:
metadata.siteName, and Course Builder stamps the sameepic-web. Without this filter, legacy would record a Course Builder sale as a secondPurchasefor the same charge. It would also send the legacy purchase email and run the post-purchase automations (Discord, bundles, ConvertKit).determineEventProcessorforwards their events bysiteName. So legacy has to stay on and skip the other app's sessions.Course Builder stamps
cbPricingContracton every checkout session it creates. skill-api never sets it, so the marker identifies the creator.Where the skip sits
/api/skill/webhook/stripe): the signature is verified, then routing bysiteNamesendsepic-web(or a missingsiteName) toself→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 theirsiteNameisepic-web.recordNewPurchasehas no other caller. The thanks and welcome pages only read.STRIPE_WEBHOOK_RECEIVED_EVENTstill goes to Inngest before routing, as it does for every event. Of its listeners, onlystripe-invoice-paidwrites anything, and it acts oninvoice.*events, not checkout sessions (see "Not covered").updatePurchaseStatusForChargedoes nothing for a charge legacy doesn't hold, so a Course Builder charge'scharge.refundedis a no-op here.How it was tested
process-stripe-webhook.test.ts(jest, 9 cases):"true"value, a marked session, an unmarked session, an empty marker, and null or missing metadata.processStripeWebhookwith the variable set: a marked session is skipped andrecordNewPurchaseis never called; an unmarked (legacy) session still records.receiveStripeWebhookswith a verified event, andreceiveInternalStripeWebhooks.pnpm --filter @skillrecordings/skill-api test: 2 suites, 10 tests pass.tsc --noEmitis clean forpackages/skill-apiandapps/epic-web, afterturbo run generate buildof their dependencies.Inert until a Course Builder session exists
No checkout session on this account carries
cbPricingContractuntil 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 toinvoice.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