Skip to content

[PM 33923]Add support for multiple organization discounts to organization subscription page#7531

Open
cyprain-okeke wants to merge 11 commits intomainfrom
billing/pm-33923/add-support-for-multiple-organization-discounts-to-organization-subscription-pag
Open

[PM 33923]Add support for multiple organization discounts to organization subscription page#7531
cyprain-okeke wants to merge 11 commits intomainfrom
billing/pm-33923/add-support-for-multiple-organization-discounts-to-organization-subscription-pag

Conversation

@cyprain-okeke
Copy link
Copy Markdown
Contributor

🎟️ Tracking

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

📔 Objective

The organization subscription page previously only supported a single discount (CustomerDiscount). This PR updates the billing infrastructure to support multiple concurrent
discounts (CustomerDiscounts) — for example, a customer may have both a Milestone 2 migration discount and a Secrets Manager standalone discount at the same time.

Changes

API Response Models:

  • OrganizationSubscriptionResponseModel — changed CustomerDiscount (single) to CustomerDiscounts (array). Organization pages pass through all discounts unfiltered so admins
    can see migration (M3/Families), SM standalone, and M2 discounts.
  • SubscriptionResponseModel — changed to CustomerDiscounts array, still filtered to M2-only for the individual user subscription page.

Core Billing:

  • SubscriptionInfo.CustomerDiscount → SubscriptionInfo.CustomerDiscounts (list).
  • StripePaymentService.GetSubscriptionAsync — collects customer-level and subscription-level discounts into a single list, deduplicating by coupon ID. Phase 2 schedule
    discounts are merged/overridden rather than replacing the whole discount.
  • GetBitwardenSubscriptionQuery — cart-level and product-level discounts are now lists; schedule phase 2 discounts return multiple entries; tax estimation passes multiple
    coupon IDs to Stripe's upcoming invoice API.
  • Cart / CartItem — Discount → Discounts (list) to model multiple discounts per item or per cart.

📸 Screenshots

Screenshot 2026-04-22 at 1 51 17 PM Screenshot 2026-04-22 at 4 29 53 PM Screenshot 2026-04-22 at 3 23 20 PM Screenshot 2026-04-22 at 2 14 46 PM

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

❌ Patch coverage is 73.46939% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.14%. Comparing base (901bb67) to head (7596c77).

Files with missing lines Patch % Lines
...g/Services/Implementations/StripePaymentService.cs 78.78% 5 Missing and 2 partials ⚠️
...esponse/Organizations/OrganizationResponseModel.cs 0.00% 4 Missing ⚠️
...Api/Billing/Controllers/OrganizationsController.cs 0.00% 1 Missing ⚠️
...c/Api/Models/Response/SubscriptionResponseModel.cs 90.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7531   +/-   ##
=======================================
  Coverage   59.14%   59.14%           
=======================================
  Files        2077     2077           
  Lines       91864    91894   +30     
  Branches     8178     8180    +2     
=======================================
+ Hits        54331    54352   +21     
- Misses      35601    35608    +7     
- Partials     1932     1934    +2     

☔ 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.

…ganization-discounts-to-organization-subscription-pag
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 22, 2026

Logo
Checkmarx One – Scan Summary & Detailsae23a18e-0a79-4674-a173-5e92a5dfc8b0

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

Copy link
Copy Markdown
Contributor

@amorask-bitwarden amorask-bitwarden left a comment

Choose a reason for hiding this comment

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

❌ There's quite a few changes here to the GetBitwardenSubscriptionQuery, which is currently only utilized for Premium. Multiple premium discounts is being addressed in PM-35121, so I believe this PR's scope extends too far. Can you ensure the changes are specifically focused on surfacing multiple organization discounts?

cyprain-okeke and others added 2 commits April 23, 2026 16:06
Remove changes to GetBitwardenSubscriptionQuery, Cart, and their tests
to keep this PR focused on organization discounts. Multiple premium
discounts will be addressed separately in PM-35121.
…ganization-discounts-to-organization-subscription-pag
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@amorask-bitwarden amorask-bitwarden left a comment

Choose a reason for hiding this comment

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

Good work - still a few things we can remove though to tighten it up.


var subscriptionInfo = await paymentService.GetSubscriptionAsync(organization);
if (subscriptionInfo?.CustomerDiscount?.Id != StripeConstants.CouponIDs.SecretsManagerStandalone)
if (subscriptionInfo?.CustomerDiscounts.Any(d => d.Id == StripeConstants.CouponIDs.SecretsManagerStandalone) != true)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (subscriptionInfo?.CustomerDiscounts.Any(d => d.Id == StripeConstants.CouponIDs.SecretsManagerStandalone) != true)
if (subscriptionInfo?.CustomerDiscounts.Any(d => d.Id != StripeConstants.CouponIDs.SecretsManagerStandalone))

Comment thread src/Api/Models/Response/SubscriptionResponseModel.cs
Copy link
Copy Markdown
Contributor

@amorask-bitwarden amorask-bitwarden left a comment

Choose a reason for hiding this comment

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

Thanks for clearing up my question. Changes look good. Nice work!

@JimmyVo16 JimmyVo16 self-requested a review April 27, 2026 13:37
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.

4 participants