Skip to content

feat: implement subscription plan templates with dynamic pricing tiers - #1

Open
Timmatt112 wants to merge 1 commit into
mainfrom
feat/950-subscription-plan-templates
Open

feat: implement subscription plan templates with dynamic pricing tiers#1
Timmatt112 wants to merge 1 commit into
mainfrom
feat/950-subscription-plan-templates

Conversation

@Timmatt112

Copy link
Copy Markdown
Owner

Summary

Closes Smartdevs17#950

Adds reusable subscription plan templates with dynamic graduated pricing tiers across the subscription contract and billing domain.

What changed

  • Added namespaced on-chain template storage keys and template lifecycle support.
  • Exposed contract APIs for creating, versioning, sharing, instantiating, quoting, listing, and analyzing templates.
  • Added safeguards for tier definitions and feature limits.
  • Prevented tiered templates from bypassing their pricing ladder via a flat price override.
  • Exported the backend template service and helpers from the billing module.
  • Added focused coverage for the tier-price override behavior.

Pricing behavior

Tiered templates use graduated pricing: each tier charges only the units inside its range. An optional final unbounded tier handles usage above the last bounded threshold. Flat templates continue to use their base price regardless of usage.

Compatibility and safety

  • Existing plan creation remains unchanged.
  • Template-created plans resolve into ordinary Plan records.
  • Superseded versions remain readable but cannot be instantiated.
  • Shared templates are instantiable by other merchants but remain owner-editable only.
  • New storage enum variants are appended to preserve existing key discriminants.

Verification

  • git diff --check passed.
  • Focused TypeScript formatting/lint hooks passed during commit.
  • Full typecheck is blocked by pre-existing errors in unrelated notification, screen, and fraud files.
  • Focused billing tests are blocked before execution by a pre-existing ErrorCode type/value issue in backend/services/shared/errors.ts.
  • Contract tests could not run because Rust/Cargo is unavailable in the environment.

Scope note

Pre-existing generated typings and package-lock.json modifications were intentionally left unstaged and are not part of this PR.

Add versioned plan templates with graduated pricing tiers, sharing, instantiation, analytics, and contract APIs. Prevent tiered templates from bypassing their pricing ladder through flat price overrides.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
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.

Implement subscription plan templates with dynamic pricing tiers

1 participant