Skip to content

[PM-33508] feat: Add AuthenticatedBillingApi and BillingService network layer#6668

Merged
SaintPatrck merged 5 commits intomainfrom
premium-upgrade/PM-33508-billing-api-service
Mar 18, 2026
Merged

[PM-33508] feat: Add AuthenticatedBillingApi and BillingService network layer#6668
SaintPatrck merged 5 commits intomainfrom
premium-upgrade/PM-33508-billing-api-service

Conversation

@SaintPatrck
Copy link
Contributor

@SaintPatrck SaintPatrck commented Mar 13, 2026

🎟️ Tracking

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

📔 Objective

Add the billing network layer for premium upgrade and subscription management flows.

New files:

  • AuthenticatedBillingApi — Retrofit interface with two endpoints:
    • POST /account/billing/vnext/premium/checkout (checkout session for free users upgrading)
    • POST /account/billing/vnext/portal-session (portal session for premium users managing subscription)
  • CheckoutSessionRequestJson / CheckoutSessionResponseJson — request/response models for checkout
  • PortalUrlResponseJson — response model for portal session
  • BillingService / BillingServiceImpl — service interface and implementation wrapping the API; platform is hardcoded to "android" in the service layer

Modified files:

  • BitwardenServiceClient / BitwardenServiceClientImpl — wire BillingService into the service client

Tests:

  • BillingServiceTest — success and failure paths for both endpoints

@SaintPatrck SaintPatrck added the ai-review Request a Claude code review label Mar 13, 2026
@github-actions github-actions bot added app:password-manager Bitwarden Password Manager app context app:authenticator Bitwarden Authenticator app context t:feature Change Type - Feature Development labels Mar 13, 2026
@claude
Copy link
Contributor

claude bot commented Mar 13, 2026

Claude finished @SaintPatrck's task in 2m 17s —— View job


  • Gather context and read changed files
  • Perform code review
  • Post review findings

Overall Assessment: APPROVE

This PR adds the AuthenticatedBillingApi, BillingService/BillingServiceImpl, and associated request/response models for the premium checkout and portal session endpoints. The implementation follows established service patterns in the network module, with proper NetworkResult to Result conversion and interface-based design. Test coverage includes success and failure cases for both endpoints using BaseServiceTest with MockWebServer.

Code Review Details

No findings identified. The code follows existing conventions for API definitions, service wrappers, serialization models, and test patterns.

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.39%. Comparing base (453fc22) to head (b1a6ab0).
⚠️ Report is 27 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6668      +/-   ##
==========================================
+ Coverage   85.72%   86.39%   +0.66%     
==========================================
  Files         847      791      -56     
  Lines       58833    56939    -1894     
  Branches     8361     8359       -2     
==========================================
- Hits        50437    49193    -1244     
+ Misses       5492     4829     -663     
- Partials     2904     2917      +13     
Flag Coverage Δ
app-data 17.67% <0.00%> (+0.21%) ⬆️
app-ui-auth-tools 20.80% <0.00%> (-0.27%) ⬇️
app-ui-platform 15.06% <0.00%> (-0.10%) ⬇️
app-ui-vault 25.83% <0.00%> (-0.70%) ⬇️
authenticator 6.64% <0.00%> (+0.03%) ⬆️
lib-core-network-bridge 4.30% <100.00%> (+0.02%) ⬆️
lib-data-ui 0.96% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@claude
Copy link
Contributor

claude bot commented Mar 13, 2026

Overall Assessment: APPROVE

Reviewed the new billing network layer: AuthenticatedBillingApi, request/response models (CheckoutSessionRequestJson, CheckoutSessionResponseJson, PortalUrlResponseJson), BillingService/BillingServiceImpl, wiring into BitwardenServiceClient, and BillingServiceTest.

Code Review Details

No findings. The implementation cleanly follows established patterns:

  • API interface uses NetworkResult<T> return type with authenticatedApiRetrofit, consistent with other authenticated APIs
  • Service converts to Result<T> via toResult(), matching the repository result pattern
  • Lazy initialization in BitwardenServiceClientImpl follows existing service wiring
  • internal visibility for API and implementation, public for service interface
  • KDoc present on all public APIs
  • Tests cover success and failure paths for both endpoints using BaseServiceTest and MockWebServer

…rk layer

Add billing network infrastructure for premium upgrade and subscription
management flows:

- AuthenticatedBillingApi with checkout session and portal session endpoints
- CheckoutSessionRequestJson/ResponseJson for premium checkout
- PortalUrlResponseJson for Stripe customer portal
- BillingService interface and implementation (platform hardcoded to "android")
- Wire BillingService into BitwardenServiceClient
@SaintPatrck SaintPatrck force-pushed the premium-upgrade/PM-33508-billing-api-service branch from 04a8dfd to c9326c4 Compare March 13, 2026 21:25
@SaintPatrck SaintPatrck marked this pull request as ready for review March 13, 2026 21:27
@SaintPatrck SaintPatrck requested review from a team and david-livefront as code owners March 13, 2026 21:28
@github-actions
Copy link
Contributor

github-actions bot commented Mar 13, 2026

Logo
Checkmarx One – Scan Summary & Details5bcd3c58-42b7-44d9-8244-835003240854


Fixed Issues (1) Great job! The following issues were fixed in this Pull Request
Severity Issue Source File / Package
MEDIUM Use_of_Hardcoded_Password /app/src/test/kotlin/com/x8bit/bitwarden/ui/vault/feature/attachments/AttachmentsViewModelTest.kt: 487

@claude
Copy link
Contributor

claude bot commented Mar 16, 2026

Overall Assessment: APPROVE

Re-reviewed incremental changes across 2 new commits since previous review: 8887374 (add returnUrl request body to portal session endpoint) and cd1756e (rename checkoutUrl to checkoutSessionUrl in CheckoutSessionResponseJson). Both commits address reviewer feedback and align with established codebase patterns. No findings.

aj-rosado
aj-rosado previously approved these changes Mar 18, 2026
Copy link
Contributor

@aj-rosado aj-rosado left a comment

Choose a reason for hiding this comment

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

LGTM, just a small nitpick

.toResult()
}

private const val PLATFORM = "android"
Copy link
Contributor

Choose a reason for hiding this comment

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

⛏️ We tend to have constant values after imports

@SaintPatrck SaintPatrck dismissed stale reviews from aj-rosado and david-livefront via b1a6ab0 March 18, 2026 16:06
@aj-rosado aj-rosado self-requested a review March 18, 2026 16:13
Copy link
Contributor

@aj-rosado aj-rosado left a comment

Choose a reason for hiding this comment

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

Thank you for moving the constant @SaintPatrck

@SaintPatrck
Copy link
Contributor Author

Thanks @aj-rosado and @david-livefront

@SaintPatrck SaintPatrck added this pull request to the merge queue Mar 18, 2026
Merged via the queue into main with commit 6d04c04 Mar 18, 2026
26 checks passed
@SaintPatrck SaintPatrck deleted the premium-upgrade/PM-33508-billing-api-service branch March 18, 2026 16:36
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 app:authenticator Bitwarden Authenticator app context app:password-manager Bitwarden Password Manager app context t:feature Change Type - Feature Development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants