mirror of
https://github.com/stack-auth/stack.git
synced 2026-07-20 21:29:36 +08:00
- Clear cancel_at_period_end when switching plans on a Stripe sub — paying to switch is an explicit "keep me subscribed", and Stripe otherwise persists the flag so the newly paid plan would still die at the period boundary. Also reset the locally written canceledAt / endedAt wind-down marks so the reactivated sub doesn't end early. - Prefer active subs over winding-down ones when several in-effect subs share a productId in the product list (partial cancel of a stackable product could otherwise hide the cancel button). - Extract isSubscriptionCancelable and use it in both the product list's is_cancelable field and the cancel route's filter, so is_cancelable: false always implies the DELETE returns 400 — for Stripe subs too, which previously re-ran the cancel silently. The cancel route now also updates the local row eagerly (mirroring the refund route) instead of waiting for the webhook sync. - Give the by-subscription-id cancel branch the same already-canceled error, and stop claiming past_due/incomplete subs are "already canceled" — they get their own message. - Treat canceled-at-period-end subs as replaceable conflicts in validatePurchaseSession, so buying another plan in the same product line during a wind-down is no longer rejected as "already has a one-time purchase". Scoped narrower than isSubscriptionInEffect so payment retries of incomplete subs aren't rejected as duplicates. - Make isSubscriptionInEffect's parameter a union so callers must actually have one of the endedAt fields, and rename resolveActivePlanSubscription to resolveInEffectPlanSubscription to match its new semantics. - Tests: unit tests for both predicates and the plan-usage wind-down resolution, a validatePurchaseSession wind-down conflict test, and e2e coverage for stackable partial-cancel shadowing, by-id double cancel, and same-line replacement during wind-down. |
||
|---|---|---|
| .. | ||
| tests | ||
| .env | ||
| .env.development | ||
| .eslintrc.cjs | ||
| LICENSE | ||
| package.json | ||
| tsconfig.json | ||
| vitest.config.ts | ||