[PM-30271] Create Retrieve Eligible Subscription Discounts Endpoint#7063
[PM-30271] Create Retrieve Eligible Subscription Discounts Endpoint#7063sbrown-livefront wants to merge 11 commits intomainfrom
Conversation
|
New Issues (1)Checkmarx found the following issues in this Pull Request
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7063 +/- ##
==========================================
+ Coverage 56.76% 56.79% +0.02%
==========================================
Files 2014 2019 +5
Lines 88218 88279 +61
Branches 7855 7861 +6
==========================================
+ Hits 50073 50134 +61
Misses 36321 36321
Partials 1824 1824 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
|
||
| // Discount services | ||
| services.AddTransient<ISubscriptionDiscountService, SubscriptionDiscountService>(); | ||
| services.AddTransient<IDiscountAudienceFilterFactory, DiscountAudienceFilterFactory>(); |
There was a problem hiding this comment.
❓ What do you think about adding the factory class as a singleton? Since it shouldn't ever need instantiated more than once, I don't think... Do you agree?
There was a problem hiding this comment.
I do! Great callout. I'll update this
| /// <inheritdoc /> | ||
| /// <remarks> | ||
| /// To add support for a new audience type: add an enum value, create a filter class, and add a case here. | ||
| /// </remarks> |
There was a problem hiding this comment.
Nice. Thanks for adding this comment here!
|
|
||
| // Assert | ||
| Assert.Null(filter); | ||
| } |
There was a problem hiding this comment.
❓ What do you think about adding a unit test here that would use reflection to loop through all of the possible values in the enum and with the exception of AllUsers, would fail if any don't have a corresponding filter returned, as a guard against the pattern not being followed?
There was a problem hiding this comment.
Ah, so I understand, if a user adds a new enum but not a filter, the unit test will show there is no corresponding filter?
Great idea.





🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-30271
📔 Objective
This pull request introduces a new API endpoint for retrieving eligible subscription discounts for a user and implements the supporting backend infrastructure for discount eligibility evaluation. It adds new service interfaces, implementations, audience filter logic, and comprehensive tests to ensure correct discount selection and mapping.
API and Controller Enhancements:
GET /discountsendpoint inAccountBillingVNextControllerthat returns all applicable subscription discounts for the authenticated user. This endpoint is feature-flagged and uses a new query interface to fetch eligible discounts.Discount Eligibility Infrastructure:
ISubscriptionDiscountServiceinterface and its implementationSubscriptionDiscountServiceto manage discount eligibility checks, including support for audience-based rules.IDiscountAudienceFilterinterface and a factory (IDiscountAudienceFilterFactory/DiscountAudienceFilterFactory) for instantiating audience filters based on discount targeting rules, with an initial implementation for "UserHasNoPreviousSubscriptions".Query and Response Models:
IGetApplicableDiscountsQueryinterface and its implementation to return eligible discounts mapped to the newSubscriptionDiscountResponseModel, which includes all relevant discount details.Dependency Injection and Service Registration:
📸 Screenshots
Screen.Recording.2026-02-24.at.10.56.01.AM.mov