Legacy: skip save logic when using saved payment method #3994
+6
−1
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.
Changes proposed in this Pull Request:
This PR fixes an edge-case scenario where we can end up unintentionally detaching saved payment methods from customers, potentially causing subscription renewals to fail.
For legacy checkout, when the customer requests to save the payment method but fails the card's auth challenge, we detach the payment method from the customer. This PR adds a condition that they were not using an already-saved payment method to begin with.
Additionally, if the customer clears the auth, we can end up saving duplicate payment method entries in
wp_woocommerce_payment_tokens
, pointing to the same Stripe payment method. This could lead to customers trying to delete the duplicates, unknowingly it also detaches the remaining payment method.Background
We have received reports where subscriptions are failing to renew with the following error message from Stripe:
@mattallan has flagged the following in p1738544815105449/1738346084.934989-slack-C3NCP7ZJ6
I have verified that this flow can lead to us detaching a payment method used by a subscription:
wc_stripe_force_save_source
filter is used)Testing instructions
4000002500003155
.Use a new payment method
, and check theSave payment information to my account for future purchases.
.Use a new payment method
to your saved payment method, and place your order.develop
, you will see/detach
requests in the logs. You will also find the payment method gone from the Stripe dashboard customers page./detach
requests, and the payment method should still be attached to the customer.Changelog entry
Changelog Entry Comment
Comment
Post merge