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

Pass the PM back to the JS to ensure it can be confirmed on the checkout if it requires 3DS confirmation #2909

Conversation

james-allan
Copy link
Contributor

Fixes #2905

Changes proposed in this Pull Request:

If you signed up to a subscription on the Block checkout, using a 3DS card, the subscription would eventually get created without a complete set of payment meta.

Screenshot 2024-02-15 at 1 18 00 pm Screenshot 2024-02-15 at 1 22 15 pm

This PR fixes that.

For some background, this change puts the block checkout inline with classic checkout.

The classic checkout handles this by passing the confirmIntent() function the payment method ID (code ref) that then leads the to the confirmIntent() function to pass the payment method ID to the update_order_status AJAX request (https://github.com/woocommerce/woocommerce-gateway-stripe/blob/fix/2905-set-payment-method-on-3ds-confirmation/client/api/index.js#L318) which then leads to the payment method being saved here.

Blocks is a little different.

Classic checkouts store the PM_ in a hidden element that can be pulled from. Block checkouts don't have that so I need to return it via the payment response (this is inline with how WooPayments does it).

On the classic checkout, the save payment method checkbox is also automatically checked if we require it to be saved (eg if the cart contains a subscription). That's not how it works on the Block checkout either. Because we don't show the checkbox, the shouldSavePayment is false. This PR makes sure it is set to true if the cart contains a subscription (ie we are required to save the payment method).

Testing instructions

  1. Enable the Woo Subscriptions plugin.
  2. Create a subscription product if you don't already have one.
  3. Place the subscription product in your cart and proceed to the block checkout page.
  4. Use a 3DS card 4000 0025 0000 3155.
  5. Complete and authorize the payment.
    • On add/deferred-intent if you view the subscription it will be missing the customer ID.
    • On this branch it should be all good.
add/deferred-intent This branch
Screenshot 2024-02-15 at 1 18 00 pmScreenshot 2024-02-15 at 1 22 15 pm Screenshot 2024-02-16 at 2 04 20 pm Screenshot 2024-02-16 at 2 07 15 pm

  • 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

@james-allan james-allan requested review from a team and Mayisha and removed request for a team February 16, 2024 05:36
Copy link
Contributor

@Mayisha Mayisha left a comment

Choose a reason for hiding this comment

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

The issue is fixed and the customer id is getting set in the subscriptions in this branch 👍

@james-allan james-allan merged commit 2d15a5d into add/deferred-intent Feb 20, 2024
32 checks passed
@james-allan james-allan deleted the fix/2905-set-payment-method-on-3ds-confirmation branch February 20, 2024 00:12
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