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

Implement Stripe Link with deferred intent UPE #6784

Merged
merged 66 commits into from
Aug 4, 2023

Conversation

FangedParakeet
Copy link
Contributor

@FangedParakeet FangedParakeet commented Jul 15, 2023

Fixes #6391
Fixes #6709
Fixes #6261

Changes proposed in this Pull Request

Linking up with Stripe Link

This implements Stripe Link in both shortcode and blocks checkouts, while using the deferred intent split UPE. The changes involved are somewhat less dramatic than they might appear. The client-side integration remains mostly the same, using the existing exportable integration with the deferred intent checkout scripts. On the server-side, we need to ensure that, when Link is enabled, link is added alongside card in the payment_method_types value sent to Stripe and we must also add a new mandate_data value, which is fortunately already an available parameter on the Payments Server.

Scattered in amongst this implementation are a few fixes to the blocks checkout parameters and some fixes to how session intent data is stored and cleared, just FYI.

Steps to enable Stripe Link

Stripe Link is only available to US stores, so you will need to onboard your test site with Stripe by using a US-based address. Other than please enable the deferred intent UPE via the dev tools and you should be able to enable Link from the Payments settings, when WooPay is disabled. If Link does still not appear on your Payments settings screen, you may need to visit the Stripe dashboard for your site's account and ensure that the Link capability is requested and active. After requesting the capability, clear your Payments Server cache and hopefully Link will appear before your eyes.

How to checkout with Stripe Link

Link is only available to US stores and consequently is also only compatible with USD at checkout. When these conditions are met, you should find that the email input rises to the top of the checkout and has a Link icon attached to it. This icon is a button that will trigger the Link checkout experience.

However, if you do not immediately see this button, you should be aware that this button is linked to the payment element and only present once this element has been mounted to the DOM. In the shortcode checkout, we mount all the payment elements immediately on page load, so this button should appear immediately without any encouragement. On the blocks checkout, however, we only mount payment elements when the relevant payment gateway is selected, so you may need to select the CC payment gateway radio button first, in order to mount the element and summon the Link button from of its slumber.

If your email address is not identified, you should trigger the registration "Save your info" checkbox to be added to the payment element; whereas if your email address is identified, you will instead trigger the OTP authentication modal to appear on top of the checkout. Note that in test mode, when you register a new Link account it will only be usable with the Stripe account where this Link account is registered and cannot be used across different sites connected to the same platform. Additionally, while registration requires a phone number, in test mode Link will never send actual SMS codes to your device: you can instead use the top-secret code 000000 every time to surpass the OTP challenge.

Testing instructions

Stripe Link should be implemented on both blocks and shortcode checkout pages, so these will need to be tested. Here are some combinations of features you should probably ensure are working.

  • Regular product checkout.
  • Checkout with subscription products.
    • Checkout with simple subscription.
    • Checkout with free-trial subscription.
    • Manual renewal for subscription.
    • Automatic renewal for subscription.
  • Check payment intent metadata.
  • Saving Link payment methods as WC Payment Tokens (apparently this is possible now).
  • Link on the Order Pay page (I think this should be possible).
  • And anything else you think might be particularly dicey.

  • Run npm run changelog to add a changelog file, choose patch to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.
  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Post merge

Timur Karimov and others added 30 commits July 3, 2023 12:15
@FangedParakeet FangedParakeet requested a review from timur27 July 25, 2023 10:30
@FangedParakeet
Copy link
Contributor Author

Created #6881 to address issues with blocks checkout and #6882 to address improvements to integration tests.

@FangedParakeet FangedParakeet requested a review from timur27 July 31, 2023 16:44
Copy link
Contributor

@timur27 timur27 left a comment

Choose a reason for hiding this comment

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

All the previous threads are now successfully closed 👍 Thanks for going through them, Samir! I've found two more things not fully working as expected:

1️⃣ Stripe Link isn't initilized with more than one payment method enabled. I'd wait for #6790 to be resolved and my hunch is the issue with Stripe Link should be resolved as well.

2️⃣ When using Stripe Link to pay for a subscription and thus saving the payment method for the future use, we get an error on the My account page while listing all the available payment methods.

Here's how it looks image

I'll try to get back to the 2️⃣nd issue after I finish #6790, since you're AFK this week.

@timur27
Copy link
Contributor

timur27 commented Aug 3, 2023

Latest changes

  1. The first problem described here was fixed in de49868.
  2. The second problem described here was fixed in cbcbef2.

Testing outcome

  1. Regular product checkout (Blocks & shortcode) ✅
  2. Checkout with subscription
    • Simple subscription purchase ✅
    • Simple subscription renewal from the My account -> Subscriptions page ✅
    • Simple subscription manual renewal from the admin panel ✅
    • Simple subscription renewal with the woocommerce_scheduled_subscription_payment action ✅
    • Free-trial subscription purchase, manual renewal from the admin panel and with woocommerce_scheduled_subscription_payment action ✅
  3. mandate_data is attached to the intent creation request ✅
  4. Able to pay for an order on the Pay for order page ✅
  5. List Stripe Link saved payment method on the My account -> Payment methods page ✅

Follow-ups

  1. Stripe Link autofill does not update fields in blocks checkout #6881
  2. Improve integration tests for deferred intent UPE #6882
  3. Create an issue for Payment gateways that are not supported by a currency are still not filtered out on the shortcode checkout page
  4. Create an issue/investigate Saved Stripe Link tokens are listed as Saved token for woocommerce_payments on Blocks checkout page
  5. Update release testing instructions or critical flows testing instructions with new functionality for Stripe Link
  6. With Stripe Link enabled, its saved payment method is visible on the checkout page even with a non-supported currency (e.g., EUR). They can also be used to perform a successful payment.

@timur27 timur27 added this pull request to the merge queue Aug 4, 2023
Merged via the queue into develop with commit df9b24e Aug 4, 2023
@timur27 timur27 deleted the add/6391-implement-stripe-link-with-deferred-intent branch August 4, 2023 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants