Skip to content

feat(payments): share adapters and verify School and Calendar checkout - #357

Merged
olliethedev merged 7 commits into
mainfrom
feat/issue-343-shared-payments
Nov 6, 2026
Merged

olliethedev merged 7 commits into
mainfrom
feat/issue-343-shared-payments

Conversation

@olliethedev

@olliethedev olliethedev commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Closes #343. School and Calendar create asynchronous checkout through the shared Core payment adapters, and grant access or confirm capacity only after signed payment verification. Ecommerce retains its existing API exports.

Core PaymentAdapter / Stripe / Lemon Squeezy
  School: pending_payment -> verified paid -> enrolled
  Calendar: pending_payment hold -> verified paid -> confirmed
                                 -> verified failure/refund -> cancelled, slot released
Ecommerce API -> Core payment re-exports

Evidence

  • Before: School expected synchronous payment confirmation; Calendar held paid slots without adapter checkout. After: 293 focused tests pass across Core, Ecommerce, School, Calendar, Analytics bridges and generator/install contracts. Regressions cover signed raw-body verification, original amount/currency/provider/reference matching, unauthorized access, credential redaction, checkout retries, concurrent webhook delivery, failure slot release and cancellation between failed hooks and retries, refund-hook retry, retained credential ownership and delayed checkout responses after identity/token changes or unmount. The merged CMS/Analytics base preserves School completion observers and Calendar reschedule context; a signed-webhook regression proves a failed enrollment event is delivered after course completion without changing completed access.
  • Affected-owner builds/typechecks (including clean School/Calendar and payment compatibility checks), changed-source Biome, documentation production build and registry generation pass. Standards/spec findings were fixed and re-reviewed; security review found no exploitable issues.
  • Real Chromium tests use the actual plugin pages, Core stack and HTTP operations in an isolated Vite fixture with a signed local test provider. They cover hosted checkout/return/reload recovery, protected lessons, held/released slots, keyboard navigation and 390px light/dark layouts. No real money is charged or external payment provider called. Packed Calendar, School and Ecommerce consumers pass strict pnpm peer validation, public declaration compilation, ESM/CommonJS operations and browser builds. Client-secret form customization is not browser-tested. Full local suite and all-framework codegen runs are left to CI.

All screenshots, recording and reproducible browser fixture · Captioned MP4 · WebM

These durable owner-accessible archive links require the owner's website login and LAN/private Tailscale access. They are not public GitHub uploads. The report and all 21 attachments passed archive verification. Every captioned frame and the five mobile screenshots were inspected. UI evidence was captured on bf784cb8; later refund, checkout-ownership and integration fixes have targeted regression coverage; the refreshed packed browser fixtures pass on b0473010.

School enrollment pending verified payment

Calendar pending hold with checkout recovery

Merge Danger

Door: one-way while pending payments exist

Migrate persistent databases before upgrading: nullable private payment text columns on schoolEnrollment and calendarBooking. Drain or cancel pending enrollments/holds before rolling back to an older runtime. School 2.0 replaces its synchronous payment callback with the shared signed asynchronous contract. The affected plugins require Core >=6.1.0; School requires CMS ^1.1.0. The CLI selects the reconciled Core 6.1 / School 2.0 / Calendar 1.1 / CMS 1.1 / Ecommerce 1.0.1 cohort. Version metadata is prepared; this PR does not publish packages.

Hosted Calendar redirects require session storage; when unavailable, the private link is preserved and checkout waits for storage to be enabled. Hosts supply a provider SDK form for client secrets through renderPayment. Hooks can run again after failure or across processes and must be idempotent by enrollment/booking ID. Abandoned holds still need application-owned cancellation.

Blast Radius: payments

Shared provider implementations are moved unchanged, Ecommerce import identity is preserved, and School/Calendar have no dependency on Ecommerce. Existing host-managed Calendar paid holds retain trusted confirmation.

@vercel

vercel Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
better-stack-docs Ready Ready Preview Nov 6, 2026 1:38pm UTC
better-stack-playground Ready Ready Preview Nov 6, 2026 1:38pm UTC

Request Review

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T13:40:33.358551Z b047301 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bf784cb892

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a73a3099fb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Bundle size

18 of 195 bundles changed.

Module Gzip base → PR Gzip change Minified change
payments (new) 0 → 95194 B +95194 B +460832 B
api 35266 → 109593 B +74327 B (+210.8%) +393254 B (+364.5%)
(root) 35274 → 109595 B +74321 B (+210.7%) +393254 B (+364.5%)
@btst/plugin-calendar/api 104931 → 106088 B +1157 B (+1.1%) +4575 B (+0.9%)
@btst/plugin-school/api 106832 → 107877 B +1045 B (+1.0%) +3666 B (+0.7%)
@btst/plugin-calendar/client/components 137695 → 138415 B +720 B (+0.5%) +2211 B (+0.4%)
@btst/plugin-calendar/client 139442 → 140136 B +694 B (+0.5%) +2213 B (+0.4%)
@btst/plugin-school/client/components 192128 → 192511 B +383 B (+0.2%) +1047 B (+0.1%)
@btst/plugin-school/client 194749 → 195095 B +346 B (+0.2%) +1047 B (+0.1%)
@btst/plugin-calendar/client/hooks 20433 → 20472 B +39 B (+0.2%) +230 B (+0.3%)

Showing the 10 largest changes by absolute gzip bytes.

172e0bd → b047301. Standalone costs; rows overlap. Moved paths appear as new/removed entries, not application savings.

Measured 22 packed archives separately; full report includes their compressed bytes without installed dependencies.

Full report and measurements

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: fdefed31f7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 1c0e20a2be

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Collaborator Author

Orchestrator integration finding from #347 / PR #363: a real external pinned consumer fails to load the new School package with published CMS 1.0 because recordContentRevision is absent. This PR's School 2.0 also imports that API while workspace:^ currently normalizes against CMS 1.0. Same-source workspace overrides do not establish compatibility with the published minimum.

PR #363 prepares CMS 1.1 and the required School CMS minimum, with a strict external consumer proving the corrected combination. Parent merge coordination will land that correction first, then refresh this candidate from latest main, preserve the CMS floor/Calendar confirmation context, reconcile the unpublished version metadata, and rerun the relevant packed checks plus exact-head CI/review/gate. Keep this PR and its lease available for that refresh; do not merge the current candidate. This is a concrete standalone-install compatibility requirement, and no package publication is authorized here.

Copy link
Copy Markdown
Collaborator Author

Confirmed the dependency-floor finding: School imports recordContentRevision while its current workspace:^ CMS dependency packs against source CMS 1.0. Current head 1c0e20a has all 62 checks green, final-head Codex review clear, and a passing repository gate receipt, but those same-source archives do not prove the published CMS minimum. I have recorded this as an unresolved integration blocker and am holding branch changes while the parent coordinates #363 before this candidate's base/cohort refresh. PR and retained lease remain available; no merge or publication performed.

Copy link
Copy Markdown
Collaborator Author

Read-only refresh preview against #363 cdd9bad found five conflicts: Calendar changelog + operations; School changelog + package + operations. I saved a resolution plan beside the retained checkpoint (issue-343-integration-refresh-plan.md), with no branch/index/source edits. Two details need preserving: Calendar payment delivery serialization plus the new reschedule confirmation context; School's conditional enrollment status guard plus the new {enrollment, completedNow} observer result/callers. Keep School 2.0 for its breaking adapter contract and verify the actual packed CMS ^1.1 minimum. Parent still owns refresh/merge sequencing; worker remains active and held.

Copy link
Copy Markdown
Collaborator Author

Native read-only composition review found another integration requirement for #363→#357: School's paid webhook retries onAfterEnroll whenever payment.status is paid, hookDelivered is false, and row.status is not cancelled (operations.ts around645–692). After a failed enrollment callback, a student can complete the course before the webhook retry. The retry then passes status completed to PR363's Analytics school.onAfterEnroll, which accepts only enrolled (bridges.ts114–120), silently skips course_enrolled, and returns successfully; School marks hookDelivered=true. Please preserve the enrollment event on this valid completed retry (or define an equivalent stable event-snapshot contract), with a composition regression. No source edits made while parent owns sequencing. Latest preview c005af7 also adds a sixth conflict in registry/btst-school.json; regenerate after resolving source.

Copy link
Copy Markdown
Collaborator Author

Executed the composition replay with built School + the upstream packed Analytics archive and a real signed local Stripe-format webhook. Confirmed: callback statuses [enrolled, completed], responses [500,200,200], Analytics attempted only once, emitted=[], final enrollment completed and hookDelivered=true. Repro and JSON receipt are issue-343-enrollment-analytics-retry-repro.mjs/.json beside checkpoints. No source mutation or live provider call. Archive source3569f45 has the same enrolled-only bridge filter reviewed at c005af7; this is defect evidence, not post-refresh validation.

Copy link
Copy Markdown
Collaborator Author

Concrete version-reconciliation detail for the saved refresh plan: incoming #363 packages/cli/src/utils/installation-set.ts still pins Core6.0.0 / School1.1.0 (correct for that standalone candidate). The payment refresh must reconcile those and existing scaffold-plan expectations to the final unpublished Core6.1 / School2 cohort, preserving CMS1.1 and Calendar1.1. Otherwise generated consumers keep selecting the earlier School contract even after source packages are refreshed. No branch/source edits made.

Copy link
Copy Markdown
Collaborator Author

Existing #343 worker is taking the refresh now that #363 merged (172e0bd), using the retained lease11 and branch. I will merge latest main, resolve the six preview conflicts, preserve CMS1.1/Calendar context and School2, reconcile generator pins, fix/test the completed-enrollment retry composition, then rerun packed and exact-head verification. No new Impulse request or helper tab; native reviewers will be reused. Parent retains merge authority.

Copy link
Copy Markdown
Collaborator Author

#363 is now merged at 172e0bd58cac27c1c739cb078292d3821a16dd4c (tested c005af70, final reviews clear, release gate passed, issue #347 closed/completed). Please refresh this same #357 branch/PR/lease onto latest main now.

Resolve the six integration conflicts from the preview, preserving the Calendar delivery queue plus reschedule confirmation context, School conditional payment state, both completion-observer callers, School 2.0/Core >=6.1 floor, and actual CMS 1.1 dependency minimum. Reconcile prepared changelog/version notes and regenerate registry from the resolved source.

The completed-enrollment retry finding is a required part of this refresh: add a real composed signed paid-webhook → enrollment sink failure → course completion → paid-webhook retry regression. Preserve the enrollment-event meaning and emit one eventual course_enrolled while pending/cancelled records remain excluded; do not fabricate an inconsistent status snapshot. A minimal safe bridge acceptance for completed active enrollments is a possible fix. The disposition is recorded at #363: #363 (comment) .

Run targeted post-resolution types/builds/tests and real pinned CMS/School/Core packed proof, then native reviews, push, exact-head Codex review and CI/gate. Reply to the findings with actual correction/verification receipts. Parent still serializes the merge. No new Impulse helpers or package publication.

Copy link
Copy Markdown
Collaborator Author

Refreshed onto merged #363 / main172e0bd in b047301. Preserved School CAS + completion observers and Calendar payment delivery queue + reschedule context; retained School2 and packed CMS^1.1/Core>=6.1 floor, with reconciled CLI cohort pins. Fixed the completed-enrollment Analytics retry; regression failed before and School21 passes after.293focused tests, affected builds/types, clean payment/School/Calendar types, Biome55, docs build, registry, and packed School/Calendar/Ecommerce ESM/CJS/types/browser fixtures pass. Native standards/spec/security reviews clear, including exact outgoing/post-hold security review; no bypass. New-head CI/deployments and separate strict pinned cohort proof are pending; parent retains merge authority.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: b0473010ed

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Collaborator Author

The strict external cohort proof now passes on exact b047301 in both ESM and CommonJS. Eight sealed candidate archives were installed with strict peers; unchanged Media/FormBuilder/Newsletter are actual published1.0.0 (gitHead1e8fe46), not same-source replacements. Packed School requires CMS^1.1.0 and installed CMS is1.1.0; all source owners resolve one candidate Core6.1. Paid School's signed callback fails once before actual Analytics ingestion, real learning completes, then two signed retries yield exactly one eventual course_enrolled plus one course_completed, completed access and durable delivery preserved. Paid Calendar holds capacity and emits one confirmation/one reschedule while legacy notifications run twice. Real ingestion hashes one shared session and strips private data. All3 generated Kysely backends compile in both module-format outputs, along with public hook/payment/client contracts; actual packed CLI Core/School/Ecommerce pins checked. Durable receipt: issue-343-refresh-cohort/status.json and result/runtime/types/seal logs beside parent checkpoints. No browser/live provider/external database in this custom fixture; separate real browser fixtures already passed. CMS floor and composition blockers are resolved locally; only final-head CI/deployments/fresh gate and late sweep remain. No merge/publication performed.

Copy link
Copy Markdown
Collaborator Author

Worker handoff: b047301 is ready for parent merge. All62exact-head checks pass, both deployments pass, final-head Codex review is completed with no findings, and the repository gate passed with matching fresh evidence. Fresh sweep read formal reviews, all inline threads including the outdated finding, and updated PR comments; all findings are addressed/resolved. Current main remains172e0bd and is an ancestor. CMS^1.1 floor, completed enrollment retry, preserved Calendar context/School observers, generator cohort,293focused tests, clean types/builds/registry/docs, three packed browser fixtures and the actual published-minimum pinned cohort proof are verified. Gate receipt: issue-343-gate-b0473010.json; handoff issue-343-status.json; all helper/artifact receipts preserved. Retaining lease11 for parent follow-up. Reporting this #343 worker success through its existing Impulse context; parent still owns the merge. No merge or package publication performed.

@olliethedev
olliethedev merged commit 0c17e00 into main Nov 6, 2026
62 checks passed

Copy link
Copy Markdown
Collaborator Author

Parent merged the verified final candidate b0473010 at 0c17e00e04b562313ae735e0bd053299da47fda8. I freshly read conversation/reviews and both inline threads (including outdated), confirmed all findings addressed/resolved and final-head Codex clear, all 62 checks/deployments green, and reran the repository gate with two matching observations at 14:03 UTC. Merge receipt is preserved; #346 is now unblocked. Existing worker/core-helper outcomes and all checkpoints/evidence are retained. No package publication performed. Worker may cleanly return only its own lease after preserving all artifacts and stopping only its owned fixture processes.

This branch was successfully deployed

2 active deployments
Preview – better-stack-docs — b0473010 Deployed Nov 6, 2026 by vercel[bot]
Preview – better-stack-playground — b0473010 Deployed Nov 6, 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.

Core & Payments: shared PaymentAdapter in @btst/stack and async webhook checkout for School and Calendar

1 participant