feat(#906): implement usage-based billing with metered pricing and tiered overages - #1067
Open
Prozaks wants to merge 2 commits into
Open
Conversation
|
@Prozaks 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! 🚀 |
…cing and tiered overages - backend/services/billing/metering.ts: pure rating engine supporting flat, graduated, volume, and package pricing with included-unit proration, minimum charges, and spend caps - contracts/metering/src: add register_tiered_meter(), quote_usage(), PricingModel/PriceTier ladder with per-tier charge breakdowns - Existing register_meter() unchanged (registers a flat meter) - Off-chain and on-chain rating implement identical arithmetic for consistency between client estimates and on-chain settlement - 391 lines of tests covering all pricing model paths - docs/USAGE_BASED_BILLING.md with API reference and examples Closes Smartdevs17#906
…e-based-billing-metered-pricing
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
Implements usage-based billing with metered pricing and tiered overage rating.
Closes #906
Changes
backend/services/billing/metering.ts(new)Pure off-chain rating engine supporting four pricing models:
Features: included-unit proration, minimum charges, spend caps, per-tier charge breakdowns.
contracts/metering/src/(updated)register_tiered_meter(): on-chain tiered meter registrationquote_usage(): on-chain usage quote returning per-tier breakdownPricingModel/PriceTiertypes in the contractregister_meter()unchanged — now registers a flat meterTests
backend/services/billing/__tests__/metering.test.ts: 391 lines covering all pricing model paths, edge cases, and spend cap enforcementcontracts/metering/src/test.rs: extended test suite for tiered contract functionsDocumentation
docs/USAGE_BASED_BILLING.md: full API reference, pricing model examples, migration guideAcceptance Criteria
Technical Scope
Covers:
contracts/metering/src/,backend/services/billing/metering.ts