[PM-31040] Replace ISetupIntentCache with customer-based approach#6954
Open
amorask-bitwarden wants to merge 31 commits intomainfrom
Open
[PM-31040] Replace ISetupIntentCache with customer-based approach#6954amorask-bitwarden wants to merge 31 commits intomainfrom
ISetupIntentCache with customer-based approach#6954amorask-bitwarden wants to merge 31 commits intomainfrom
Conversation
…ser table definitions
…d Dapper implementation
…pper implementation
… index configuration
…ry instead of cache
…tPaymentMethodQuery
…sPaymentMethodQuery
…etupIntent and query by customer
…dHostedSubscriptionCommand
…od and UserService.ReplacePaymentMethodAsync
…query Stripe by customer ID Add Task 15a to plan - this was a missed requirement for updating GetPaymentSourceAsync which still used the cache.
…lize and UserService.SignUpPremiumAsync
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6954 +/- ##
==========================================
+ Coverage 60.21% 60.32% +0.10%
==========================================
Files 1976 1976
Lines 87536 87135 -401
Branches 7810 7758 -52
==========================================
- Hits 52714 52562 -152
+ Misses 32907 32672 -235
+ Partials 1915 1901 -14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
|
New Issues (2)Checkmarx found the following issues in this Pull Request
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.





🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-31040
📔 Objective
Replace the
ISetupIntentCachedistributed cache with a customer-based approach that directly associates StripeSetupIntentobjects with StripeCustomerobjects. This eliminates infrastructure dependencies on the distributed cache and simplifies the codebase by removing dead code paths.Problem
The
SetupIntentDistributedCachemaintained a bidirectional mapping between subscriber IDs and SetupIntent IDs, which was fragile and caused issues with the bank account payment method flow for organizations and providers.Solution
Instead of caching the SetupIntent-to-subscriber relationship:
customerfield on theSetupIntentwhen it's retrieved (during subscription creation or payment method update)GatewayCustomerIdwhen webhooks arrive, using new repository methodsChanges
Database Infrastructure (Phase 1-3)
GatewayCustomerIdandGatewaySubscriptionIdGatewayCustomerIdandGatewaySubscriptionIdcolumns for all three entity tablesSetupIntent Handling Updates (Phase 4-5)
SetupIntentSucceededHandlerto query repositories by customer ID instead of using the cacheStripeEventServiceby expanding customer data directly from SetupIntentGetPaymentMethodQueryandHasPaymentMethodQueryto query Stripe by customer IDOrganizationBillingService,ProviderBillingService, andUpdatePaymentMethodCommandto set the customer on SetupIntentsDead Code Removal (Phase 6-7)
CreatePremiumCloudHostedSubscriptionCommand(premium users cannot use bank accounts)UpdatePaymentMethodfromOrganizationBillingService,ProviderBillingService, andPremiumUserBillingService(replaced byUpdatePaymentMethodCommand)UpdatePaymentSourcefromSubscriberServiceSignUpPremiumAsyncandReplacePaymentMethodAsyncfromUserService(orphaned at API layer)FinalizefromPremiumUserBillingServiceISetupIntentCacheandSetupIntentDistributedCache📸 Screenshots
Screen.Recording.2026-02-05.at.1.40.26.PM.mov
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:) or similar for great changes:memo:) or ℹ️ (:information_source:) for notes or general info:question:) for questions:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:) for suggestions / improvements:x:) or:warning:) for more significant problems or concerns needing attention:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt:pick:) for minor or nitpick changes