A downgrade on a subscription with two items removes the other item at Stripe #233
Open
opened 2026-10-16 02:59:54 +00:00 by cgalo5758
·
1 comment
Labels
Clear labels
accessibility
area/billing
area/catalog
area/discourse
area/domains
area/entitlements
area/fedwiki
area/identity
area/integrations
area/licensing
area/member-ui
area/meta
area/operator-ui
area/ops
area/testing
duplicate
good-first-issue
invalid
privacy
security
upstream
wontfix
A barrier for people using assistive technology or a keyboard alone.
The Stripe mirror, checkout, subscriptions, invoices, fulfillment.
Products, prices, plan ladders, purchasability.
The Discourse integration.
The domains registry, claims, placements, the certificate ask.
Entitlement sets, rules, grants, pools, provisioning.
The Federated Wiki integration and farm sync.
Sign-in, sessions, persons, organizations, workspaces, roles.
The provider registry, outbox and webhooks in general.
Licenses, the contributor agreement, SPDX headers.
Member pages.
The repository itself, its contributing guide, CI, the tracker and the workflow.
Operator pages, forms, lists, the design system.
Deployment, configuration, migrations, workflows, instance settings.
The test stack, screens, lint, walkthroughs.
Closed because another issue already covers it.
Small, self-contained, and explained enough to be a first contribution.
Closed because it is not a ticket for this repository.
Touches what a person's data reveals.
Touches authentication, authorization, secrets or data exposure.
Waits on another repository or project before it can move.
Closed because it will not be done, with the reason in the last comment.
kind
bug
The software does something other than what it promises; closed when it again does what it promises.
kind
debt
Code, tests or tooling to clean up with nothing visible changing; closed when they are cleaner.
kind
design
A question to settle before work can be defined; closed when the decision is written down.
kind
docs
Documentation that is wrong or missing; closed when it says the right thing.
kind
enhancement
Something the software does not do yet; closed when it does.
priority
critical
Blocks the active milestone or harms members now.
priority
high
Next in line inside the active milestone.
priority
low
Inside the active milestone, when nothing else is left.
priority
medium
Inside the active milestone, after the high ones.
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: wiki-cafe/member-console#233
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What happens
A member's downgrade waits for the renewal.
downgradeAtRenewal(internal/fulfillment/plan_change.go:339) attaches a Stripe subscription schedule with two phases: the current price until the period ends, then the lower price. It builds both phases from one item, the first one Stripe lists on the subscription (current.Items.Data[0], lines 344 and 373-394). Phase one holds only that item's price and quantity. Phase two holds only the target price.A schedule phase lists every item the subscription carries during that phase, and Stripe removes an item a phase leaves out. The console's Checkout creates a subscription with one item, and on those the schedule is right. But an edit at Stripe can add a second item, and the reconcile records every item and confers each item's product (#200 describes the same case on the plan card). The switch already knows which item belongs to the ladder:
resolveLadderSubscription(line 704) picks the item whose product is the ladder's current tier, and the upgrade sends that item's id.On a subscription whose two items each pay for a tier on a different ladder:
findSpentSchedule,internal/fulfillment/reconcile.go:892) and releases it. The lower tier never starts.I have not run this against Stripe. Both outcomes follow from how Stripe applies a schedule's phases and from the reconcile's rules.
What should happen
The schedule changes only the ladder's own item. Phase one carries every current item at its current price and quantity. Phase two carries the same items, with the ladder's item, the one
resolveLadderSubscriptionfound, moved to the target price.Where
internal/fulfillment/plan_change.go:339-416(downgradeAtRenewal).Steps
Why it matters
A member who downgrades one plan loses another plan they pay for, or loses the plan they downgraded at once instead of at renewal. Stripe's billing changes on the spot, and nothing tells the member.
Related: #219 changes how the downgrade attaches its schedule; the phases it writes stay as they are.
The switch the sweeper fires at the end of a commitment term reads the first item the same way.
firePlanSwitch(internal/fulfillment/sweep.go:183) moves the subscription's first current item to the target price (GetSubscriptionItemsBySubscriptionID, thenitems[0], lines 200-204), andscheduledChangeMappings(line 233) checks the environment of that same first item before the switch fires (lines 248-252). A member's move is deferred to the term's end when the plan's early-termination policy blocks it before then (internal/fulfillment/plan_change.go:255-272). On a subscription with two items, such a switch can reprice the other ladder's item, and since items recorded in one reconcile share theircreated_at(#200), which item moves is not fixed. The fix this issue describes, choosing the ladder's own item the wayresolveLadderSubscriptiondoes, applies here too.