feat(billing): subscription billing with usage metering - #989
Merged
github-actions[bot] merged 2 commits intoSep 28, 2026
Merged
github-actions[bot] merged 2 commits into
github-actions[bot] merged 2 commits into
Conversation
|
@davidsoniaudin2-oss is attempting to deploy a commit to the smartdevs17's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@davidsoniaudin2-oss Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
) Adds plans with recurring base fees and included usage allowances, idempotent usage-event ingestion, graduated/flat overage pricing, invoice generation with itemized base and metered lines, period rollover that resets counters, and cancel-at-period-end handling. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
davidsoniaudin2-oss
force-pushed
the
feat/914-subscription-usage-metering
branch
from
September 28, 2026 03:46
55da1a8 to
70befd5
Compare
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
Closes #914.
Adds subscription plans with a recurring base price and included usage allowance, plus metered overage billed per billing period.
What changed
backend/src/services/subscription-billing.ts—SubscriptionBillingService: plans (flat or graduatedtiers), subscriptions with optional trials, idempotent usage events, usage summaries, invoice generation with itemized base + metered lines, period rollover that resets counters, and cancel-at-period-end.backend/src/routes/subscription-billing.ts— REST API mounted at/api/v1/billing(plans, subscriptions, usage, invoices).backend/src/index.ts— router registration.docs/SUBSCRIPTION_USAGE_BILLING.md— feature documentation including pricing rules.Behaviour notes
overageUnitPriceor progressively throughtiers, with usage past the last tier falling back to the flat rate.idempotencyKeyreturns the original event instead of double-counting.close-periodinvoices the period, rolls the subscription forward and clears usage.Tests
backend/src/services/__tests__/subscription-billing.test.ts— 24 tests covering plan validation, subscription/trial creation, aggregation, idempotency, flat and graduated overage math, invoices, period rollover, and transitions. All passing; typecheck and lint clean for the new files.Verification