feat(billing): charge and report Stripe service fees - #5383
Open
jeanduplessis wants to merge 26 commits into
Open
feat(billing): charge and report Stripe service fees#5383jeanduplessis wants to merge 26 commits into
jeanduplessis wants to merge 26 commits into
Conversation
Introduce the assessment and exemption tables, plus the operator runbook and ADR that define one assessment per commercial event. No runtime billing behavior changes yet.
On-call runbooks live in kilo-org/on-call. Leave the ADR here as the engineering record.
Co-authored-by: kilo-code-bot[bot] <240665456+kilo-code-bot[bot]@users.noreply.github.com>
Co-authored-by: kilo-code-bot[bot] <240665456+kilo-code-bot[bot]@users.noreply.github.com>
Land the fee math, durable assessments, Checkout/invoice attach helpers, and refund/dispute observers without wiring them into payment paths. Pin the Stripe API version so line-shape assumptions stay stable.
Stop treating Stripe gross paid amounts as product value. Settlement now reads a trusted principal, classifiers ignore fee lines, and Impact Kilo Pass sales use the product amount. No fee is charged yet.
Attach the 5% fee to personal and organization Checkout top-ups and auto top-up invoices. Refund and dispute webhooks now observe fee assessments. Kilo Pass charging is still unwired.
Attach fees to personal and organization Kilo Pass Checkout and Stripe-advanced invoices, including org seat-capacity updates.
Add the org exemption admin UI, fee-vs-product revenue reporting, and read-only Kilo Pass classification and restricted-coupon audits.
This was referenced Aug 19, 2026
Contributor
|
Are no Stripe fees being charged until November? The email said "September 1". If so, this would be great! |
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
Adds the complete Stripe service-fee implementation for eligible credit top-ups and Kilo Pass purchases, with durable fee assessments, trusted product-principal settlement, exemptions, lifecycle adjustments, fee-only reporting, and rollout audits.
Why this change is needed
A 5% Stripe line item alone is not enough to operate the fee safely. The platform must distinguish product principal from the added fee so credits, entitlements, affiliate value, and product analytics do not use gross payment amounts. It must also retain fee decisions when no line is charged, survive Stripe webhook ordering and retries, handle refunds and disputes, support reasoned organization exemptions, and report collected or missed fees without turning the sidecar into a second payment ledger.
This PR replaces the six-PR stack in #5236, #5262, #5263, #5264, #5265, and #5266 so the complete behavior can be reviewed and merged as one unit.
How this is addressed
credit_transactionsrevenue series and report assessment-backed fee metrics separately by UTC settlement date, including collected, missed, exempted, and disputed amounts.Human Verification
.plans/service-fees/PRAGMATIC-SIDECAR.mdand confirmed the fee sidecar does not become a product or payment ledger./admin/revenuewith fake local data: assessment-backed credits remained in Paid Revenue, Kilo Pass produced a fee-only UTC day, refund/dispute overlap clamped collected fees to zero, empty ranges rendered correctly, and CSV output used the narrowed fee-only shape.Reviewer Notes
Human Reviewer Flags
credit_transactionsremains authoritative for the existing product-revenue series.Code Reviewer Agent
Code Reviewer Notes
GREATEST(charged - refunded - disputed, 0)before aggregation.settled_atand grouped in UTC. Assessment rows are never anti-joined out of the existing credit-revenue query.