Repository navigation
Land billing-core Phase 4: Stripe event and snapshot translation - #4
Conversation
Phase 4 adapter maps verified Stripe events and subscription objects onto LedgerEvent / snapshot fetches. The core stays provider-agnostic; signature verification and host repo.js swaps stay out of this tree. Co-authored-by: Fly Over Coder <FlyOverCoder@gmail.com>
|
You have reached your Codex usage limits for security reviews. Please try again later. |
Annotate the same-second rank loop so tsc does not treat the application decision as an implicit any. Co-authored-by: Fly Over Coder <FlyOverCoder@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2472a89813
ℹ️ 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".
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5ab3c17. Configure here.
Drop the id+status fallback that treated PaymentIntents, Checkout Sessions, and Invoices as subscriptions. Wrappers now unwrap an expanded Subscription or return null. Co-authored-by: Fly Over Coder <FlyOverCoder@gmail.com>

Phase 4 of Billing Core:
@pegma/billing-stripetranslates verified Stripe events and subscription snapshots into the Phase 1–3 ledger. The core stays provider-agnostic.What landed
@pegma/billing-stripe(0.1.0, unpublished)LifecycleStatus(incomplete_expired→canceled;paused→unpaidso a same-secondactivecannot resurrect it)translateStripeEventtakes a host-verified Event and writesevent.id/event.createdas the ledger watermarktranslateStripeSubscriptioncopies identifiers and derived state only — never card data, raw payloads, line items, or amountscreateStripeSnapshotFetcher/createStripeBillingAdapterkeep the vendor client behindretrieveSubscriptionstripe, never callsDate.now(), and never processes a payment or resolves an entitlementTests cover:
canceledvsactivein both arrival orders, throughdecideLedgerApplicationandledger.applyledger.reconcilepayment_intent.canceleddoes not write api_…subscription id; Checkout Session and Invoice objects with their ownid+statusunwrap the expanded SubscriptionReview follow-up
5ab3c17annotates the same-second rank loop sotscdoes not treat the application decision as an implicit any.fc488berestrictssubscriptionRecordto a real Subscription (object === "subscription", or a discriminator-lesssub_…retrieve). PaymentIntents and similar no longer become ledger events. Checkout Session / Invoice wrappers unwrap the expanded Subscription instead of matching onid+status.Explicitly not in this PR
repo.jsswap (Phase 5)Plan status is Phase 4 in-tree, unpublished. Do not merge from this PR unless a reviewer asks. Do not publish or tag.
Local gate:
pnpm run format:check,pnpm run check,pnpm test— 158 tests passed.