fix(billing): filter mixed subscription seat items#3037
Merged
jeanduplessis merged 3 commits intomainfrom May 5, 2026
Merged
Conversation
Non-seat products (Kilo Pass, KiloClaw add-ons, etc.) are currently summed into the organization seat count because PR #1609 was squash-merged from a branch based on pre-fix code, silently reverting commit 55b8424 and its follow-up 5d21daa. This causes double-counting for organizations with mixed product subscriptions — e.g., FSKAB (060090ad-e0ec-4612-a2d2-935b1c74a60f) shows 54 seats (27 seats + 27 Kilo Pass line items) when it should show 27. Re-apply the product-ID-based filter in handleSubscriptionEventInternal: only subscription items whose price.product matches the Teams or Enterprise seat product contribute to seat_count and amount_usd. Derive the billing period (starts_at / expires_at) from the first filtered seat line item so a non-seat add-on appearing first in the list cannot corrupt the period. Also restore the ~154 lines of tests that were removed, updating the base mock subscription to use STRIPE_TEAMS_SUBSCRIPTION_PRODUCT_ID so existing tests continue to exercise the seat path, and update the two no-line-item error assertions to match the new, more specific error message.
Contributor
Author
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (6 files)
Reviewed by gpt-5.5-20260423 · 701,273 tokens |
jeanduplessis
approved these changes
May 5, 2026
jrf0110
reviewed
May 5, 2026
jrf0110
approved these changes
May 5, 2026
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
Fix mixed Stripe subscription handling so only Teams/Enterprise seat product line items contribute to organization seat records and seat-count updates.
The bug is real for subscriptions that contain seat products alongside Kilo Pass or other non-seat add-ons: unfiltered subscription items can inflate
organizations.seat_count, purchaseamount_usd, and downstream paid-seat update calculations. This branch reapplies the previously proposed seat-product filtering from closed PR #1060 on top of currentmain; the earlier PR text's claim that PR #1609 reverted a merged fix has been corrected here.Key changes:
seat_count,amount_usd, billing period, and billing cycle.Verification
Manual/code verification only:
Visual Changes
N/A — server-side billing logic and tests only.
Reviewer Notes
main; this PR should be reviewed as applying that fix now, not as a literal revert of PR feat(billing): add monthly billing cycle for Team and Enterprise seats #1609.