Tier 1 Stripe fidelity — sub updates, test clock billing, 3DS#2
Merged
Tier 1 Stripe fidelity — sub updates, test clock billing, 3DS#2
Conversation
- Move SSE unsubscribe to cancel() where ReadableStream spec calls it - Replace Math.random() with crypto.randomBytes for client secrets - Initialize invoice counter from DB row count to survive restarts
Covers subscription updates, test clock billing, 3DS simulation, and subscription update events.
7 tasks: 3DS magic tokens, requires_action state, subscription updates, cancel events, test_clock on sub create, clock-driven billing, final verification.
…end, trial_end, metadata
… TestClockService Move actionFlags from dashboard/api.ts to lib/action-flags.ts to fix service→dashboard dependency inversion. Remove PriceService dep from TestClockService (injected but never called).
…add past_due test
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.
Summary
POST /v1/subscriptions/:idwith item swap,cancel_at_period_end,trial_end, metadata. Emitscustomer.subscription.updatedevents withprevious_attributes.tok_threeDSecureRequired/tok_threeDSecureOptional. Payment intents enterrequires_actionwithnext_action, re-confirm completes the flow.advance()now triggers subscription period rollovers, invoice creation (withbilling_reason: "subscription_cycle"), auto-finalize, and auto-pay. Handles trial-to-active transitions andpast_dueon payment failure.Math.random→crypto.randomBytesfor client secrets, invoice counter survives restarts.Test plan
bun test), 0 failuresbun x tsc --noEmit)bun test tests/sdk/)tok_threeDSecureRequired→ confirm PI →requires_action→ re-confirm →succeededtest_clock, advance pastcurrent_period_end, verify invoice created and sub period rolled