Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Split PE] Fixes error on block checkout when attempting to pay for failed renewal with a saved card #2906

Merged
merged 2 commits into from
Feb 19, 2024

Conversation

mattallan
Copy link
Contributor

Fixes #2904

Changes proposed in this Pull Request:

This issue is fairly edge case, nevertheless, after changing a subscription's payment method via the My Account > View Subscription page, this incorrectly stores the _stripe_setup_intent metadata on the subscription which then gets copied to future renewal orders.

If a renewal order fails and has this setup_intent data, when a customer attempts to pay for the renewal order with a saved card on the checkout block, they will get an error on the checkout.
image

After digging into error there are actually two main issues at play:

  1. Block checkout isn't always setting the wc-stripe-is-deferred-intent data, when using a standard Stripe saved card. This causes the process_payment() function to call process_payment_with_saved_payment_method() instead of the expected process_payment_with_deferred_intent(). Fixed by 7d32890
  2. When changing a subscriptions payment method from the My Account > View Subscription page, we're saving the setup intent on the subscription which is then being copied to all future renewal orders. This setup intent is then being used to attempt payment which won't work. 8b08b23

Testing instructions

  1. Enable UPE gateway and checkout add/deferred-intent branch
  2. Set a block checkout as your default checkout.
  3. Checkout add/deferred-intent
  4. Purchase a subscription using a successful card (i.e. 4242)
  5. From the My Account > View subscription page, change the payment method on your subscription to a card that will fail on the next renewal i.e. 4000000000000341
  6. Process a renewal order from the WP Admin Edit Subscription actions drop-down
  7. From My Account click "Pay" next to the most recent failed order
  8. Attempt to use the saved 4242 card to fix up the failed renewal order
  9. Notice the checkout fails
  10. Checkout this branch and attempt to use the saved card again to fix up the failed order. It should succeed.

  • Covered with tests (or have a good reason not to test in description ☝️)
  • Added changelog entry in both changelog.txt and readme.txt (or does not apply)
  • Tested on mobile (or does not apply)

Post merge

Copy link
Contributor

@james-allan james-allan left a comment

Choose a reason for hiding this comment

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

Changes look good and worked for me.

I confirmed that this does fix the issue of trying to pay for a failed renewal order after a payment method change.

I also confirmed with the changes that setup intent ID were being recorded on subscriptions, but aren't anymore on this branch.

@mattallan mattallan merged commit 3376ade into add/deferred-intent Feb 19, 2024
32 checks passed
@mattallan mattallan deleted the fix/2904-paying-for-failed-renewal branch February 19, 2024 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants