Skip to content

fix(kilo-pass): void collectible Stripe invoices on cancel - #5409

Merged
eshurakov merged 4 commits into
mainfrom
session/agent_d2484b89-3d25-4b3a-9e33-8f83243722bb
Aug 21, 2026
Merged

fix(kilo-pass): void collectible Stripe invoices on cancel#5409
eshurakov merged 4 commits into
mainfrom
session/agent_d2484b89-3d25-4b3a-9e33-8f83243722bb

Conversation

@eshurakov

Copy link
Copy Markdown
Contributor

Summary

Canceling Kilo Pass only set cancel_at_period_end, so Stripe kept retrying failed or pending invoices. This stops collection by abandoning collectible invoices before scheduling cancellation.

  • Void open invoices for the Stripe subscription
  • For drafts, disable auto_advance, finalize, then void (instead of deleting drafts)
  • Do not persist cancellation if abandoning invoices fails
  • Ignore invoices that are already paid, void, uncollectible, or missing

Test plan

  • oxlint on the four changed kilo-pass files
  • pnpm typecheck --changes-only
  • pnpm --filter web test -- src/lib/kilo-pass/abandon-collectible-invoices.test.ts src/routers/kilo-pass-router.test.ts (139 passed)

kilo-code-bot Bot and others added 3 commits August 20, 2026 19:12
Canceling Kilo Pass only set cancel_at_period_end, so Stripe kept retrying
failed or pending invoices. Void open invoices and delete drafts after
scheduling cancellation so collection stops.
Instead of deleting draft invoices, which may not be the preferred way to handle abandoned subscriptions in Stripe, this change updates draft invoices to disable `auto_advance`, finalizes them, and then voids them. This ensures a more controlled lifecycle for collectible invoices during the cancellation process.

- Update `abandonCollectibleInvoicesForStripeSubscription` to use `finalizeDraftThenVoid` for draft invoices
- Replace `stripe.invoices.del` with a sequence of `update`, `finalizeInvoice`, and `voidInvoice`
- Update tests to reflect the new invoice handling logic and mock the new Stripe method calls
Keep the Stripe invoice helper aligned with the id/status fields it
reads so unit mocks typecheck without full Invoice fixtures.
Comment thread apps/web/src/lib/kilo-pass/abandon-collectible-invoices.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • apps/web/src/lib/kilo-pass/abandon-collectible-invoices.ts
  • apps/web/src/lib/kilo-pass/abandon-collectible-invoices.test.ts
  • apps/web/src/routers/kilo-pass-router.ts
  • apps/web/src/routers/kilo-pass-router.test.ts
Previous Review Summary (commit 112d8bc)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 112d8bc)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/kilo-pass/abandon-collectible-invoices.ts 66 Finalizing draft subscription invoices can advance the billing cycle
Files Reviewed (4 files)
  • apps/web/src/lib/kilo-pass/abandon-collectible-invoices.ts - 1 issue
  • apps/web/src/lib/kilo-pass/abandon-collectible-invoices.test.ts
  • apps/web/src/routers/kilo-pass-router.ts
  • apps/web/src/routers/kilo-pass-router.test.ts

Fix these issues in Kilo Cloud


Reviewed by grok-4.6 · Input: 183K · Output: 7.1K · Cached: 101.6K

Review guidance: REVIEW.md from base branch main

Finalizing subscription drafts can advance current_period_end before
cancel_at_period_end is set. Disable auto_advance on drafts instead.

@pandemicsyn pandemicsyn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@eshurakov
eshurakov merged commit 2748bb1 into main Aug 21, 2026
18 checks passed
@eshurakov
eshurakov deleted the session/agent_d2484b89-3d25-4b3a-9e33-8f83243722bb branch August 21, 2026 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants