Skip to content

[PM-30271] Create Retrieve Eligible Subscription Discounts Endpoint#7063

Merged
sbrown-livefront merged 43 commits intomainfrom
billing/pm-30271/fetch-discounts-endpoint
Mar 3, 2026
Merged

[PM-30271] Create Retrieve Eligible Subscription Discounts Endpoint#7063
sbrown-livefront merged 43 commits intomainfrom
billing/pm-30271/fetch-discounts-endpoint

Conversation

@sbrown-livefront
Copy link
Copy Markdown
Collaborator

@sbrown-livefront sbrown-livefront commented Feb 24, 2026

🎟️ 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:

  • Added a new GET /discounts endpoint in AccountBillingVNextController that 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:

  • Introduced the ISubscriptionDiscountService interface and its implementation SubscriptionDiscountService to manage discount eligibility checks, including support for audience-based rules.
  • Added the IDiscountAudienceFilter interface and a factory (IDiscountAudienceFilterFactory/DiscountAudienceFilterFactory) for returning DI filters based on discount targeting rules, with an initial implementations for "UserHasNoPreviousSubscriptions" and "AllUsers".

Query and Response Models:

  • Created the IGetApplicableDiscountsQuery interface and its implementation to return eligible discounts mapped to the new SubscriptionDiscountResponseModel, which includes all relevant discount details.

Dependency Injection and Service Registration:

  • Registered all new services, queries, and filter factories in the payment service registration module to ensure proper DI resolution.

Stripe Integration and Constants

  • Expanded StripeConstants to include product IDs and a utility to map Stripe product IDs to discount tiers, and added a method to list subscriptions via Stripe.

API Response Model

  • Added SubscriptionDiscountResponseModel to standardize the API response for discount information, including per-tier eligibility.

Note: Stripe Product IDs are no longer returned with discounts

📸 Screenshots

Screen.Recording.2026-03-03.at.10.51.35.AM.mov

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 24, 2026

Logo
Checkmarx One – Scan Summary & Detailsdbc85790-8a12-4c53-8d04-56beb7b51734

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

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 24, 2026

Codecov Report

❌ Patch coverage is 95.60440% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.52%. Comparing base (cc12c72) to head (8702e47).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...nceFilters/UserHasNoPreviousSubscriptionsFilter.cs 93.05% 3 Missing and 2 partials ⚠️
...ces/Implementations/SubscriptionDiscountService.cs 93.75% 0 Missing and 2 partials ⚠️
.../Billing/Services/Implementations/StripeAdapter.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7063      +/-   ##
==========================================
+ Coverage   56.44%   56.52%   +0.07%     
==========================================
  Files        2013     2020       +7     
  Lines       88089    88270     +181     
  Branches     7855     7875      +20     
==========================================
+ Hits        49720    49892     +172     
- Misses      36554    36559       +5     
- Partials     1815     1819       +4     

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

@kdenney kdenney self-requested a review February 25, 2026 21:12
@sbrown-livefront sbrown-livefront self-assigned this Feb 25, 2026
@sbrown-livefront sbrown-livefront requested a review from kdenney March 2, 2026 21:23
Copy link
Copy Markdown
Contributor

@kdenney kdenney left a comment

Choose a reason for hiding this comment

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

Looking good and getting closer! 👏 A few notes and suggestions.

@sbrown-livefront sbrown-livefront requested a review from kdenney March 3, 2026 16:28
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

@kdenney kdenney left a comment

Choose a reason for hiding this comment

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

Looks good; nice job!

@sbrown-livefront sbrown-livefront merged commit ee84237 into main Mar 3, 2026
45 checks passed
@sbrown-livefront sbrown-livefront deleted the billing/pm-30271/fetch-discounts-endpoint branch March 3, 2026 18:39
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