Skip to content

Feat: Add Organization Subscription-Preview Endpoint - #8245

Draft
sbrown-livefront wants to merge 15 commits into
billing/PM-39925/invoice-preview-projectionfrom
billing/PM-39927/org-subscription-preview
Draft

Feat: Add Organization Subscription-Preview Endpoint#8245
sbrown-livefront wants to merge 15 commits into
billing/PM-39925/invoice-preview-projectionfrom
billing/PM-39927/org-subscription-preview

Conversation

@sbrown-livefront

@sbrown-livefront sbrown-livefront commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

🎟️ Tracking

Stacked on PM-39925 (invoice-preview foundation). Base is billing/PM-39925/invoice-preview-projection, not mainmain has none of the Bit.Invoicing / Bit.Subscriptions.Organization libraries this builds on. Review after the foundation PRs (#8208, #8209) merge.

📔 Objective

First endpoint on the new Bit.Subscriptions.Organization feature library and first consumer of the shared, Stripe-invoice-preview–driven cart summary. Sources the organization's upcoming-renewal cart totals from an actual Stripe invoice preview instead of reconstructing them from local subscription state.

Adds:

  • GetSubscriptionPreviewQuery (Bit.Invoicing) — shared, ISubscriber-generic query ported from GetBitwardenSubscriptionQuery. Resolves tier/cadence (collapsing TeamsStarter → Teams), previews via create_preview(subscription=id), falls back to the subscription overload when there's no upcoming invoice, and maps subscription status → SubscriptionPreview envelope (suspension/grace-period/cancel). Registered in AddInvoicing(). The Organization path is fully wired here; the User/Premium path is stubbed for Task 8.
  • GET /organizations/{organizationId:guid}/billing/subscription/preview — new route on the org subscription group, gated behind PM36631_PreviewDrivenCart.
  • Authorization via AuthorizeAttribute<OrganizationBillingRequirement> using the IOrganizationRequirement framework (Owner or confirmed provider-user-for-org; excludes Admin/Custom). Lives entirely in the OrganizationAuthorization library — no dependency on the Api project.
  • Unit tests for the query, the requirement, and the endpoint handler + group wiring.

Refactor (cross-cutting): AuthorizeAttribute moved into the dedicated OrganizationAuthorization library and its namespace updated. Consumers were re-pointed to the new namespace — a one-line using change across ~15 AdminConsole/Billing controllers, the PAM AccessRuleEndpoints, NoopAuthorizeAttribute, and two test files. This accounts for the otherwise-unrelated file churn; no behavior changes.

Confirmed during implementation: create_preview(subscription=id) surfaces a subscription schedule's phase-2 discount, so the legacy GetSchedulePhase2CouponIdsAsync porting was not needed.

Out of scope: Provider subscribers (ResolveTierAndCadenceAsync throws); the User/Premium route (Task 8).

📸 Screenshots

N/A — internal API endpoint, no UI in this PR.

@sbrown-livefront sbrown-livefront changed the title [PM-39928] feat: add organization subscription-preview endpoint Feat: Add Organization Subscription-Preview Endpoint Aug 21, 2026
@sbrown-livefront sbrown-livefront self-assigned this Aug 21, 2026
@sbrown-livefront sbrown-livefront added the t:feature Change Type - Feature Development label Aug 21, 2026
@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.69231% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.41%. Comparing base (eaeb91c) to head (ad72c4f).

Files with missing lines Patch % Lines
...icePreviews/Queries/GetSubscriptionPreviewQuery.cs 79.51% 13 Missing and 4 partials ⚠️
...ion/OrganizationSubscriptionEndpointsExtensions.cs 80.00% 1 Missing ⚠️
Additional details and impacted files
@@                               Coverage Diff                               @@
##           billing/PM-39925/invoice-preview-projection    #8245      +/-   ##
===============================================================================
+ Coverage                                        63.39%   63.41%   +0.02%     
===============================================================================
  Files                                             2420     2423       +3     
  Lines                                           104400   104504     +104     
  Branches                                          9472     9483      +11     
===============================================================================
+ Hits                                             66182    66269      +87     
- Misses                                           35946    35959      +13     
- Partials                                          2272     2276       +4     

☔ View full report in Codecov by Harness.
📢 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t:feature Change Type - Feature Development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant