Skip to content

[PM-33899] Release schedule on terminal subscription operations#7305

Merged
amorask-bitwarden merged 3 commits intomainfrom
billing/PM-33899/release-schedule-terminal
Mar 26, 2026
Merged

[PM-33899] Release schedule on terminal subscription operations#7305
amorask-bitwarden merged 3 commits intomainfrom
billing/PM-33899/release-schedule-terminal

Conversation

@amorask-bitwarden
Copy link
Copy Markdown
Contributor

@amorask-bitwarden amorask-bitwarden commented Mar 25, 2026

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-33899

📔 Objective

Introduces IPriceIncreaseScheduler — a shared service that consolidates subscription schedule creation and release logic behind the PM32645_DeferPriceMigrationToRenewal feature flag. Previously, schedule creation lived as a private method in UpcomingInvoiceHandler and release guards were inlined at each call site.

Schedule(Subscription) — Creates a two-phase subscription schedule that defers a price increase to the renewal date. Resolves the subscriber type via SubscriberId metadata to determine the correct migration path (Premium or Families), builds the appropriate Phase 2 configuration (target price + discount), and creates the schedule in Stripe. Returns bool so callers can skip downstream processing (e.g., renewal emails) when a schedule already exists.

Release(string customerId, string subscriptionId) — Releases any active schedule for the subscription, cancelling a pending deferred price increase. Logs and re-throws on failure, requiring manual release via the Stripe Dashboard.

Call sites:

  • UpcomingInvoiceHandler — calls Schedule during invoice.upcoming processing (replaces the private SchedulePriceMigrationAsync)
  • SubscriptionUpdatedHandler — calls Release when a subscription goes unpaid; calls Schedule when a subscription recovers (recreates the schedule)
  • UpgradePremiumToOrganizationCommand — calls Release before upgrading to an org plan
  • SetUpSponsorshipCommand — calls Release before applying a sponsorship

📸 Screenshots

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 25, 2026

Logo
Checkmarx One – Scan Summary & Details5a48ff82-724b-4a29-accc-e338e5e7bcdc

Great job! No new security vulnerabilities introduced in this pull request

@amorask-bitwarden amorask-bitwarden marked this pull request as ready for review March 25, 2026 14:16
@amorask-bitwarden amorask-bitwarden requested a review from a team as a code owner March 25, 2026 14:16
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Codecov Report

❌ Patch coverage is 83.02752% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.94%. Comparing base (89f6e43) to head (9cd250d).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
src/Core/Billing/Pricing/PriceIncreaseScheduler.cs 81.77% 31 Missing and 4 partials ⚠️
...Services/Implementations/UpcomingInvoiceHandler.cs 60.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7305      +/-   ##
==========================================
+ Coverage   57.91%   57.94%   +0.03%     
==========================================
  Files        2044     2045       +1     
  Lines       90130    90243     +113     
  Branches     8018     8026       +8     
==========================================
+ Hits        52199    52295      +96     
- Misses      36066    36080      +14     
- Partials     1865     1868       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Collaborator

@sbrown-livefront sbrown-livefront left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 ❇️ Abstracts a lot from that handler. Good stuff!

Comment thread src/Core/Billing/Pricing/PriceIncreaseScheduler.cs
@amorask-bitwarden amorask-bitwarden merged commit 54c3e4a into main Mar 26, 2026
80 of 87 checks passed
@amorask-bitwarden amorask-bitwarden deleted the billing/PM-33899/release-schedule-terminal branch March 26, 2026 20:00
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.

3 participants