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

Amazon Pay ECE: add payment flow using confirmation tokens #3741

Merged
merged 20 commits into from
Jan 28, 2025

Conversation

annemirasol
Copy link
Contributor

@annemirasol annemirasol commented Jan 17, 2025

Fixes #3737

Changes proposed in this Pull Request:

To set the stage for Amazon Pay, we need to introduce a payment flow that uses confirmation tokens instead of manually created payment methods.

Since Amazon Pay does not support paymentMethodCreation: manual, we cannot use the same payment element to create all express checkout buttons.

This PR makes the following changes:

  • We add a "confirmation token" branch to deferred intent payment processing
  • For product page, classic cart, classic checkout and Pay-for-Order pages, we split the express checkout payment types: creating one payment element for each type.
    • This is already our approach for block cart and block checkout.
    • As we are splitting the express payment types (and as such, we have to mount them in children divs under the main div), the width/layout for the express payment buttons have slightly changed. See comments for the before and after.

Testing instructions

  1. Purchase items using ECE on the different pages that we display them: product page, classic/block checkout, classic/block cart, and Pay-for-Order page. Purchases should behave as expected.
    • As all of our express payment types are set to use manual payment method creation, this is a regression check. Everything should behave the same way as before.
  2. Purchase products using non-express payment methods, e.g. credit card, Klarna. Purchases should behave as expected.
  3. To test the newly-added confirmation tokens flow, uncomment https://github.com/woocommerce/woocommerce-gateway-stripe/pull/3741/files#r1927748266, which will set Google Pay to use the new flow. Do not forget to rebuild your source afterwards.
  4. With Google Pay set to use confirmation tokens, purchase items using Google Pay on the different pages where we display them.
  5. In wp-admin, check that the orders get set to "Processing" or "Completed". With confirmation tokens, you may have to wait a few minutes (around 3-5 mins) for it.
  6. Test confirmation token flow + manual capture:
    • In Stripe Settings > Transaction Preferences, turn on "capture later".
    • Verify that you can purchase items without any problem.
    • Similar to automatic capture, it may take a few minutes for the order status to change from "Pending payment" to "On hold".
    • Change the status to "Processing" to capture the payment.

  • 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

@annemirasol annemirasol force-pushed the add/3737-confirmation-token-payment-flow branch from d5d7c44 to 6588548 Compare January 17, 2025 22:55
@annemirasol annemirasol self-assigned this Jan 21, 2025
@annemirasol annemirasol force-pushed the add/3737-confirmation-token-payment-flow branch 8 times, most recently from 9612d93 to 35cf126 Compare January 23, 2025 22:08
Comment on lines 352 to 357
// TODO: Uncomment me to test Google Pay on confirmation token flow.
// Remove me before merging to production.
// if ( [ 'googlePay', 'google_pay' ].includes( expressPaymentType ) ) {
// return false;
// }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👆 Uncomment this section to test the confirmation token flow, using Google Pay.

@annemirasol
Copy link
Contributor Author

This PR changes the way we render the express payment buttons in non-block pages: they are now rendered separately to allow for elements with different payment configs.

As such, the way the buttons look have slightly changed. LMK if you see any problems with this, or if you can think of a way to avoid surprising our merchants with a potential layout change.

Before After
Screenshot 2025-01-23 at 4 30 40 PM Screenshot 2025-01-23 at 4 30 10 PM
Screenshot 2025-01-23 at 4 38 16 PM Screenshot 2025-01-23 at 4 38 48 PM

@annemirasol annemirasol force-pushed the add/3737-confirmation-token-payment-flow branch from b3df848 to af462fc Compare January 24, 2025 16:38
@annemirasol annemirasol force-pushed the add/3737-confirmation-token-payment-flow branch 2 times, most recently from e6865c0 to 574c853 Compare January 24, 2025 16:57
@annemirasol annemirasol force-pushed the add/3737-confirmation-token-payment-flow branch from c8a6961 to a47d535 Compare January 24, 2025 17:17
@annemirasol annemirasol force-pushed the add/3737-confirmation-token-payment-flow branch from b3306c3 to a970393 Compare January 24, 2025 18:59
@annemirasol annemirasol marked this pull request as ready for review January 24, 2025 20:23
@annemirasol annemirasol requested review from a team and wjrosa and removed request for a team January 24, 2025 20:25
@wjrosa
Copy link
Contributor

wjrosa commented Jan 27, 2025

👋 hi! It looks like changelog.txt and readme.txt needs to be updated

@wjrosa
Copy link
Contributor

wjrosa commented Jan 27, 2025

This PR changes the way we render the express payment buttons in non-block pages: they are now rendered separately to allow for elements with different payment configs.

As such, the way the buttons look have slightly changed. LMK if you see any problems with this, or if you can think of a way to avoid surprising our merchants with a potential layout change.

Before After
Screenshot 2025-01-23 at 4 30 40 PM Screenshot 2025-01-23 at 4 30 10 PM
Screenshot 2025-01-23 at 4 38 16 PM Screenshot 2025-01-23 at 4 38 48 PM

I think it is OK for this PR, but we might want to create a new issue to handle this later. Some merchants do complain about these kind of changes.

Copy link
Contributor

@wjrosa wjrosa left a comment

Choose a reason for hiding this comment

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

Nice work, Anne! Code is nice and it mostly works as intended:

  1. Purchase items using ECE on the different pages that we display them: product page, classic/block checkout, classic/block cart, and Pay-for-Order page. Purchases should behave as expected.

Product page:
Screenshot 2025-01-27 at 10 45 21

Classic checkout:
Screenshot 2025-01-27 at 10 53 50

Block checkout:
Screenshot 2025-01-27 at 10 57 47

Classic cart:
Screenshot 2025-01-27 at 11 02 27

Blocks cart:
Screenshot 2025-01-27 at 11 01 10

Pay for order:
Screenshot 2025-01-27 at 11 05 33

  1. Purchase products using non-express payment methods, e.g. credit card, Klarna. Purchases should behave as expected.
Screenshot 2025-01-27 at 11 10 03
  1. With Google Pay set to use confirmation tokens, purchase items using Google Pay on the different pages where we display them.
    ❌ I get this on any page after removing that comment
Screenshot 2025-01-27 at 11 15 23
  1. In wp-admin, check that the orders get set to "Processing" or "Completed". With confirmation tokens, you may have to wait a few minutes (around 3-5 mins) for it.
    ❌ Not possible to test due the previous error
  1. Test confirmation token flow + manual capture:
  • Verify that you can purchase items without any problem.
  • Change the status to "Processing" to capture the payment.
    ❌ Not possible to test due the previous error

@annemirasol
Copy link
Contributor Author

With Google Pay set to use confirmation tokens, purchase items using Google Pay on the different pages where we display them.
❌ I get this on any page after removing that comment
Screenshot 2025-01-27 at 11 15 23

Oof 😓, sorry about that. I added a last-minute tweak in 817749a to support manual captures and ended up breaking automatic capture. Fixed in f124d78, and tested for both scenarios!

@wjrosa
Copy link
Contributor

wjrosa commented Jan 27, 2025

With Google Pay set to use confirmation tokens, purchase items using Google Pay on the different pages where we display them.
❌ I get this on any page after removing that comment
Screenshot 2025-01-27 at 11 15 23

Oof 😓, sorry about that. I added a last-minute tweak in 817749a to support manual captures and ended up breaking automatic capture. Fixed in f124d78, and tested for both scenarios!

Works now! Thanks for fixing the issue 👍

@annemirasol annemirasol merged commit 3b13d22 into develop Jan 28, 2025
35 of 37 checks passed
@annemirasol annemirasol deleted the add/3737-confirmation-token-payment-flow branch January 28, 2025 04:31
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.

Amazon Pay ECE: support payment processing via confirmation tokens
2 participants