Skip to content

Feat: Add Organization Subscription-Preview Endpoint - #8245

Merged
sbrown-livefront merged 26 commits into
mainfrom
billing/PM-39927/org-subscription-preview
Aug 31, 2026
Merged

Feat: Add Organization Subscription-Preview Endpoint#8245
sbrown-livefront merged 26 commits into
mainfrom
billing/PM-39927/org-subscription-preview

Conversation

@sbrown-livefront

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

Copy link
Copy Markdown
Collaborator

🎟️ Tracking

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

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

@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 87.61905% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.69%. Comparing base (17a1912) to head (ae3f392).

Files with missing lines Patch % Lines
...icePreviews/Queries/GetSubscriptionPreviewQuery.cs 85.54% 9 Missing and 3 partials ⚠️
...ion/OrganizationSubscriptionEndpointsExtensions.cs 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8245      +/-   ##
==========================================
+ Coverage   63.67%   63.69%   +0.02%     
==========================================
  Files        2467     2470       +3     
  Lines      105693   105798     +105     
  Branches     9551     9562      +11     
==========================================
+ Hits        67295    67388      +93     
- Misses      36082    36091       +9     
- Partials     2316     2319       +3     

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

@kdenney
kdenney force-pushed the billing/PM-39925/invoice-preview-projection branch 2 times, most recently from a72b6a3 to 72c51a8 Compare August 24, 2026 17:31
@sbrown-livefront
sbrown-livefront force-pushed the billing/PM-39927/org-subscription-preview branch from ad72c4f to 6f86df0 Compare August 24, 2026 18:03
@sbrown-livefront sbrown-livefront added the ai-review Request a Claude code review label Aug 24, 2026
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

Reviewed the incremental changes since the last round: the Bit.Invoicing README dependency-table correction, three merges from main, and the PAM using swap to Bit.OrganizationAuthorization. Re-verified the GetSubscriptionPreviewQuery status/tier mapping and Stripe fallback path, the OrganizationBillingRequirement authorization (Owner or confirmed provider user, enforced at the group level), the handler's NotFoundException paths against WithBasicExceptionHandling, and the DI registrations. Confirmed every call site of AuthorizeAttribute<T> carries the new namespace after the move, and that all seven packages.lock.json files referencing subscriptions.organization were regenerated for the new OrganizationAuthorization project reference (project references only — no new or upgraded NuGet packages).

No new findings. The two carried-over items remain as previously acknowledged cleanup-task work: OrganizationBillingRequirement duplicating ManageOrganizationBillingRequirement, and the OrganizationAuthorization library's remaining files still declaring the Bit.Api.AdminConsole.Authorization namespace.

Comment thread src/Api/Startup.cs Outdated
@sbrown-livefront
sbrown-livefront marked this pull request as ready for review August 24, 2026 20:25
@sbrown-livefront
sbrown-livefront requested review from a team as code owners August 24, 2026 20:25
@sbrown-livefront
sbrown-livefront requested review from BTreston and cyprain-okeke and removed request for a team August 24, 2026 20:25
@kdenney
kdenney force-pushed the billing/PM-39925/invoice-preview-projection branch from 72c51a8 to 2bcc3d0 Compare August 25, 2026 14:58
@kdenney
kdenney requested review from a team as code owners August 25, 2026 14:58
@kdenney
kdenney force-pushed the billing/PM-39925/invoice-preview-projection branch from 2bcc3d0 to 01a50dd Compare August 25, 2026 15:53
@sbrown-livefront
sbrown-livefront force-pushed the billing/PM-39927/org-subscription-preview branch from dd2eb84 to 400d063 Compare August 25, 2026 21:01
Comment thread src/Libraries/OrganizationAuthorization/AuthorizeAttribute.cs
BTreston
BTreston previously approved these changes Aug 26, 2026

@BTreston BTreston left a comment

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.

Approved for AC changes

@kdenney
kdenney force-pushed the billing/PM-39925/invoice-preview-projection branch from 01a50dd to e58bcfd Compare August 26, 2026 19:23
Base automatically changed from billing/PM-39925/invoice-preview-projection to main August 26, 2026 20:00
@kdenney
kdenney dismissed BTreston’s stale review August 26, 2026 20:00

The base branch was changed.

@sbrown-livefront
sbrown-livefront force-pushed the billing/PM-39927/org-subscription-preview branch from df4eccc to 63e3371 Compare August 27, 2026 14:49
Comment thread src/Libraries/Invoicing/InvoicePreviews/Queries/GetSubscriptionPreviewQuery.cs Outdated
Comment thread src/Libraries/Invoicing/README.md Outdated

@amorask-bitwarden amorask-bitwarden left a comment

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.

Looks great, nice work.

@sbrown-livefront
sbrown-livefront removed the request for review from a team August 31, 2026 15:30
Hinton
Hinton previously approved these changes Aug 31, 2026

@Hinton Hinton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Pam is just namespace change.

@sbrown-livefront
sbrown-livefront merged commit 27de6da into main Aug 31, 2026
51 checks passed
@sbrown-livefront
sbrown-livefront deleted the billing/PM-39927/org-subscription-preview branch August 31, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review t:feature Change Type - Feature Development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants