Skip to content

Refactor metered plan configuration#2432

Open
JackVeneyMIRK wants to merge 7 commits into
OneUptime:masterfrom
JackVeneyMIRK:master
Open

Refactor metered plan configuration#2432
JackVeneyMIRK wants to merge 7 commits into
OneUptime:masterfrom
JackVeneyMIRK:master

Conversation

@JackVeneyMIRK
Copy link
Copy Markdown
Contributor

@JackVeneyMIRK JackVeneyMIRK commented May 6, 2026

Title of this pull request?

Refactor metered plan configuration

Small Description?

This pull request refactors how metered plan Stripe price IDs are managed for billing, moving away from hardcoded values in the codebase to using environment variables. This change improves security, flexibility, and ease of configuration across different environments (production, staging, testing). It also updates the test utilities to ensure these environment variables are set during tests and documents the new variables in the example environment configuration.

Billing Service Refactor:

  • Replaces hardcoded Stripe price IDs in BillingService.getMeteredPlanPriceId with environment variables, throwing descriptive errors if not configured. This makes the billing logic environment-agnostic and easier to manage.

Testing Improvements:

  • Adds a helper (ensureMeteredPlanPriceIdsInTestEnv) in test utilities to set default test values for the new environment variables, ensuring tests remain stable and do not fail due to missing configuration.
  • Updates test setup functions to call this helper, guaranteeing required environment variables are always present in test runs.

Configuration Documentation:

  • Adds the new environment variables for metered plan Stripe price IDs to config.example.env so users know to configure them for each product type.

Pull Request Checklist:

  • Please make sure all jobs pass before requesting a review.
  • Put closes #XXXX in your comment to auto-close the issue that your PR fixes (if such).
  • Have you lint your code locally before submission?
  • Did you write tests where appropriate?

Related Issue?

Screenshots (if appropriate):

Refactor email handling in BillingService to simplify parsing and usage of financeAccountingEmail. Update sendInvoiceByEmail method to accept a single recipientEmail instead of an array.
Add metered plan Stripe price IDs to config.
Added a function to ensure metered plan price IDs are set in the test environment.
@simlarsen
Copy link
Copy Markdown
Contributor

simlarsen commented May 6, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Add cross-env as a dependency and update the lint and fix-lint npm scripts to set NODE_OPTIONS via cross-env (replacing export ...) for cross-platform compatibility. Also update package-lock.json to reflect the dependency changes.
Adjust indentation for BillingService.getMeteredPlanPriceId and remove extra blank lines/trailing whitespace in BillingServiceHelper test utilities. These are purely formatting changes with no logic modifications.
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.

2 participants