Repository navigation
fix(billing): cancel the Stripe subscription on account deletion - #213
Merged
Merged
Conversation
- delete_account cancels a live subscription via DELETE /v1/subscriptions/{id} before dropping any row, with a per-account Idempotency-Key; any other Stripe failure fails closed with a clear message.
- Already-canceled/missing subscriptions (404 resource_missing, canceled body) count as success so retries are safe; late webhooks for deleted users stay recorded 200 no-ops.
- Removed the admin billing_ack stopgap (UI + API): self-deletion and admin deletion share the same automatic cancel. Docs and delete modals note the immediate cancel with no automatic refund.
- Checks: cargo fmt --check, cargo clippy --all-targets --locked -D warnings, targeted lib tests (billing::, console_billing::, console_account::, console_admin_users::, mcp delete_account), bun run validate.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 15 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Independent-review follow-up on #213. When the account has a Stripe customer, delete_account now lists the customer's subscriptions (GET /v1/subscriptions?customer, status=all, has_more paginated) plus the stored id, and cancels each billable one with a per-subscription Idempotency-Key delete-account-{account}-{sub}. A failed list or any failed cancel fails closed; an empty list is success. A deletion step that fails after a successful cancel answers the retry-safe message instead of the generic internal error (per-subscription idempotency keys make a retry free). Fake Stripe serves settable list pages (second page after starting_after) with list-outage and per-id cancel-failure modes; new tests: two live subs both canceled then deleted, pagination followed, second-cancel failure and list failure keep the account. Stripe-level list tests pin filtering, paging and outage. Mapper unit tests pin the post-cancel message. Checks: cargo fmt --check, cargo clippy --all-targets --locked -D warnings, targeted lib tests (accounts::, billing::, console_billing::, console_account::, console_admin_users::, mcp delete_account) 136 passed, bun run validate.
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.
Security-review fix: deleting an account left a live Stripe Pro subscription billing the customer.
What:
accounts::delete_account(the one path self-deletion and the admin delete share) cancels a live subscription viaDELETE /v1/subscriptions/{id}before dropping any row, with a per-accountIdempotency-Keyso a retry is safe. Any other Stripe failure fails closed: no rows deleted, clear message ("We couldn't cancel your Pro subscription, so the account wasn't deleted. Try again or contact support.").StripeClient::cancel_subscriptiontreats 404resource_missingandcanceledbodies as success.customer.subscription.deleted→ recorded 200, no resurrected row).billing_ackstopgap (API field + gate, console checkbox/warning): the shared path now cancels automatically. Delete modals and account-deletion docs note the immediate cancel with no automatic refund (Stripe default).Why: a deleted account kept billing — fail-open data deletion with live billing.
Checks run (all green):
cargo fmt --all --checkcargo clippy --all-targets --locked -- -D warnings(only the pre-existing tower-http unused-dep warn)billing::,http::console_billing::,http::console_account::,http::console_admin_users::,mcp::tests::delete_account— 127 passed, 0 failedbun run validate(web)No prod touched, no live Stripe calls. Awaiting independent review before merge.