[PM-31771]Default payment method not updated within subscription#7253
Open
cyprain-okeke wants to merge 2 commits intomainfrom
Open
[PM-31771]Default payment method not updated within subscription#7253cyprain-okeke wants to merge 2 commits intomainfrom
cyprain-okeke wants to merge 2 commits intomainfrom
Conversation
Contributor
|
Great job! No new security vulnerabilities introduced in this pull request |
…updated-within-subscription
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7253 +/- ##
=======================================
Coverage 57.68% 57.68%
=======================================
Files 2035 2035
Lines 89647 89649 +2
Branches 7994 7995 +1
=======================================
+ Hits 51709 51711 +2
+ Misses 36074 36073 -1
- Partials 1864 1865 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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-31771
📔 Objective
This PR fixes a bug where the payment method was not being properly updated when restarting a canceled organization
subscription through the resubscribe flow.
Background
When an organization owner restarted a canceled subscription by providing a new payment method via the
/subscription/restartendpoint, the old payment method was still being used to charge the subscription instead of the newly provided payment method.
Changes
RestartSubscriptionCommand.cs: Added explicit fetching of the customer's current default payment method and passingit to the SubscriptionCreateOptions when creating the new subscription
RestartSubscriptionCommandTests.cs: Added mocks for GetCustomer and assertions to verify DefaultPaymentMethod isexplicitly set in all success scenarios
Technical Details
Previously, the subscription restart flow relied on Stripe's OffSession = true parameter to automatically use the customer's
default payment method. However, this could result in using a stale/cached payment method due to timing issues between updating
the payment method and creating the subscription.
The fix explicitly fetches the customer object after the payment method has been updated and passes the DefaultPaymentMethodId
to the SubscriptionCreateOptions, ensuring the correct payment method is always used regardless of Stripe's caching behavior.
Testing
Fixes: [Issue tracking payment method update bug during subscription restart]
📸 Screenshots
Before the Fix Video
Screen.Recording.2026-03-19.at.2.05.04.PM.mov
After the Fix Video
Screen.Recording.2026-03-19.at.1.57.44.PM.mov