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

WooPay compatibility with deferred intent creation UPE #6656

Merged
merged 23 commits into from
Jul 18, 2023

Conversation

timur27
Copy link
Contributor

@timur27 timur27 commented Jul 3, 2023

Closes #6291

Changes proposed in this Pull Request

Currently, split UPE with the deferred intent creation on the server is implemented in all flows, including shortcode & Blocks checkout and My account subpages, such as Payment methods, Subscriptions, Pay for order. The time has come for the WooPay to be compatible with this UPE type as well, thus this PR ensures that WooPay's functionality previously used only in pair with the legacy card gateway, is now entirely usable with the deferred intent creation UPE as well.

Testing instructions

💡 Ensure your WCPay Server listens to Stripe webhooks.

Legacy card/legacy UPE/split UPE all disabled in WCPay Dev Tools. Only deferred intent creation UPE is enabled.
WooPay is enabled in Payments -> Settings.
Only card payment method is enabled in Payments -> Settings. Act as a logged-in user.

1️⃣

  1. Add a product to the cart and navigate the shortcode checkout.
  2. On shortcode checkout, input default card details, billing details, and the email which isn’t yet registered with WooPay
  3. Confirm that the Save my information for a faster checkout checkbox is displayed under the card gateway. Don’t check this checkbox yet.
  4. Place the order and confirm that the order status is Processing, and on the Stripe side - payment in status Succeeded
  5. Repeat steps 1-2, then check the Save my information for a faster checkout checkbox and place the order.
  6. Confirm you were redirected to an order placed page.
  7. On WooPay's site admin panel, navigate to Users and confirm that the user with the email you used in step 5 is now visible on the list.
  8. On the Stripe Customers page (e.g., https://dashboard.stripe.com/test/customers), confirm that the user is also listed.

Now, since you have the user registered in WooPay, check the following:

2️⃣

  1. Add a product to the cart and proceed to the shortcode checkout page again.
  2. The email should be already provided but if not - provide the email of the previously registered user.
  3. Confirm that WooPay's pop-up modal appears on the page asking you to provide the OTP code for verification.
  4. After entering 000000 make sure you're redirected successfully to the checkout page with all the cart details.
  5. After adding a new payment method/new shipping address if needed, on the WooPay checkout page, click Place Order and confirm you're redirected to the merchant's order summary page stating the order was received successfully, and the payment method is a card with WooPay icon on the left.
  6. Navigate to http://host.docker.internal:8090/account/orders and confirm that the order placed is listed there.
  7. Ensure the order status is correct in WC -> Orders and Stripe payments.
  8. Log out after the previous steps, and navigate to the shortcode checkout so that the email field is empty
  9. Click the WooPay Express Checkout button and enter the registered email
  10. Complete the checkout with WooPay and confirm the order is successful

Enable all the other available payment methods in Payments -> Settings, so that not only card appears on the list.

  1. Perform the above two test blocks again with the list of enabled payment gateways.

Incognito window

Place an order with WooPay in the incognito window.

Cart page

On the cart page, use the WooPay express checkout button and provide the email in the WooPay to checkout using WooPay. Confirm that the checkout went successfully.

Product page

On the product page (e.g. a Beanie) use the express checkout button to test new user registration flow and checking out using the existing email address.

Blocks checkout

Perform testing instructions from 1️⃣ and 2️⃣ on the Blocks checkout page.

Other UPEs

  • Enable split UPE and disable deferred intent creation UPE. Enable WooPay. Go to the checkout page and confirm that the legacy card gateway is loaded as expected. Disable WooPay and confirm that the card gateway (Stripe Payment Element) is rendered.
  • Perform sanity checks for the split UPE (e.g. buy a product and a subscription to double-check there's no regression)
  • Perform sanity checks for the legacy UPE (same as above)

class-checkout-service.php was extended a bit. Below are the changes and how to test them (and changes in class-payment-information as well):

  1. create_intention_request method is used for all the legacy card payments and card payments within the deferred intent creation. This means, that you will probably have this method tested after all the above steps but if still unsure - just enable legacy gateway (non-UPE) or deferred intent UPE and purchase any product with a card.
  2. create_and_confirm_setup_intention_request was slightly modified as well. To test it out, enable legacy gateway (non-UPE) or deferred intent creation UPE, and purchase a free trial subscription. Ensure that the payment was processed successfully.

  • 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

@botwoo
Copy link
Collaborator

botwoo commented Jul 3, 2023

Test the build

Option 1. Jetpack Beta

  • Install and activate Jetpack Beta.
  • Use this build by searching for PR number 6656 or branch name feature/deferred-intent-woopay in your-test.site/wp-admin/admin.php?page=jetpack-beta&plugin=woocommerce-payments

Option 2. Jurassic Ninja - available for logged-in A12s

🚀 Launch a JN site with this branch 🚀

ℹ️ Install this Tampermonkey script to get more options.


Build info:

  • Latest commit: 3af7500
  • Build time: 2023-07-17 09:37:12 UTC

Note: the build is updated when a new commit is pushed to this PR.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 3, 2023

Size Change: +4 kB (0%)

Total Size: 1.25 MB

Filename Size Change
release/woocommerce-payments/dist/blocks-checkout.js 39.7 kB +69 B (0%)
release/woocommerce-payments/dist/checkout.js 28.4 kB +57 B (0%)
release/woocommerce-payments/dist/payment-request.js 11.6 kB +57 B (0%)
release/woocommerce-payments/dist/upe_checkout.js 33.9 kB +65 B (0%)
release/woocommerce-payments/dist/upe_split_checkout.js 34.4 kB +37 B (0%)
release/woocommerce-payments/dist/upe_with_deferred_intent_creation_checkout.js 35.5 kB +3.56 kB (+11%) ⚠️
release/woocommerce-payments/dist/upe-blocks-checkout.js 39.4 kB +51 B (0%)
release/woocommerce-payments/dist/upe-split-blocks-checkout.js 40.8 kB +51 B (0%)
release/woocommerce-payments/dist/woopay-express-button.js 16.7 kB +53 B (0%)
ℹ️ View Unchanged
Filename Size
release/woocommerce-payments/assets/css/admin.css 1.03 kB
release/woocommerce-payments/assets/css/success.css 158 B
release/woocommerce-payments/dist/blocks-checkout.css 1.4 kB
release/woocommerce-payments/dist/checkout.css 444 B
release/woocommerce-payments/dist/index.css 38.8 kB
release/woocommerce-payments/dist/index.js 283 kB
release/woocommerce-payments/dist/multi-currency-analytics.js 1.05 kB
release/woocommerce-payments/dist/multi-currency-switcher-block.js 60.5 kB
release/woocommerce-payments/dist/multi-currency.css 2.91 kB
release/woocommerce-payments/dist/multi-currency.js 55.3 kB
release/woocommerce-payments/dist/order.css 728 B
release/woocommerce-payments/dist/order.js 40.4 kB
release/woocommerce-payments/dist/payment-gateways.css 704 B
release/woocommerce-payments/dist/payment-gateways.js 38.7 kB
release/woocommerce-payments/dist/product-details.js 777 B
release/woocommerce-payments/dist/settings.css 8.76 kB
release/woocommerce-payments/dist/settings.js 198 kB
release/woocommerce-payments/dist/subscription-edit-page.js 669 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.css 527 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.js 20.2 kB
release/woocommerce-payments/dist/subscription-product-onboarding-toast.js 693 B
release/woocommerce-payments/dist/subscriptions-empty-state.css 298 B
release/woocommerce-payments/dist/subscriptions-empty-state.js 19.4 kB
release/woocommerce-payments/dist/tos.css 236 B
release/woocommerce-payments/dist/tos.js 21.7 kB
release/woocommerce-payments/dist/upe_checkout.css 444 B
release/woocommerce-payments/dist/upe_split_checkout.css 444 B
release/woocommerce-payments/dist/upe-blocks-checkout.css 1.4 kB
release/woocommerce-payments/dist/upe-split-blocks-checkout.css 1.41 kB
release/woocommerce-payments/dist/woopay.css 4.06 kB
release/woocommerce-payments/dist/woopay.js 70.4 kB
release/woocommerce-payments/includes/subscriptions/assets/css/plugin-page.css 633 B
release/woocommerce-payments/includes/subscriptions/assets/js/plugin-page.js 720 B
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/i18n-loader.js 2.43 kB
release/woocommerce-payments/vendor/automattic/jetpack-assets/src/js/i18n-loader.js 1.01 kB
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-ajax.js 522 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-callables.js 581 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/babel.config.js 160 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.css 2.32 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.js 13.8 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.rtl.css 2.32 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/about.css 1.2 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-order-statuses.css 403 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin.css 3.56 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/checkout.css 299 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/modal.css 742 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/view-subscription.css 572 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/wcs-upgrade.css 411 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin-pointers.js 544 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin.js 9.07 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.js 6.8 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.min.js 3.83 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-coupon.js 544 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-subscription.js 2.38 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.js 22.1 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.min.js 11.6 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/payment-method-restrictions.js 1.29 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/wcs-meta-boxes-order.js 502 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/payment-methods.js 355 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/single-product.js 429 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/view-subscription.js 1.38 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/wcs-cart.js 781 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/modal.js 1.1 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/wcs-upgrade.js 1.27 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.css 392 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.js 3.06 kB

compressed-size-action

Comment on lines +1360 to +1366
if ( ! empty( $upe_payment_method ) && 'woocommerce_payments' !== $upe_payment_method ) {
$payment_methods = [ str_replace( 'woocommerce_payments_', '', $upe_payment_method ) ];
} elseif ( WC_Payments_Features::is_upe_split_enabled() || WC_Payments_Features::is_upe_deferred_intent_enabled() ) {
$payment_methods = [ 'card' ];
} else {
$payment_methods = WC_Payments::get_gateway()->get_payment_method_ids_enabled_at_checkout( null, true );
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It always confuses me how this conditional logic here works...but I'm pretty sure it does and I suppose that's what's important lol. 😂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I see what you mean. In this PR, I just moved this logic from the process_payment_for_order method without any modification. I did so to be able to re-use it properly. Overall, this method needs a re-visit, most probably during split-upe/legacy-upe cleanup.

@timur27 timur27 requested a review from FangedParakeet July 12, 2023 12:15
Copy link
Contributor

@FangedParakeet FangedParakeet left a comment

Choose a reason for hiding this comment

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

LGTM!

Finally managed to test this properly: ran it through both the shortcode and blocks checkouts using as many permutations of regular product, subscription, and free-trial subscriptions using multiple accounts with regular payment methods and 3DS payment methods requiring additional authentication and I could not get this implementation to either bend nor break. Nice one! Tip top tidy job. :shipit:

@timur27
Copy link
Contributor Author

timur27 commented Jul 17, 2023

@FangedParakeet Thanks for your review! Today I've added one more commit (3af7500), which ensures that payment methods addition under My account page works appropriately for the deferred intent UPE. I'd appreciate it if you could take a look at this commit - if everything's alright, please approve the PR once more - this will signal me that we're ready to merge.

Thanks!

Copy link
Contributor

@FangedParakeet FangedParakeet left a comment

Choose a reason for hiding this comment

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

Nice catch! It looks like we're now supplying all the valid parameters whenever that Payment Information is required. LGTM.

Spent a bit of time testing pre-existing split-UPE checkout flows, just for my own sanity, and everything appears to be running as expected. Double-checking the code, I don't believe there's anything in here that would conflict with any existing flows in any other gateways, so I think we're good to go now! 🚢

@timur27 timur27 added this pull request to the merge queue Jul 18, 2023
Merged via the queue into develop with commit 69a0508 Jul 18, 2023
@timur27 timur27 deleted the feature/deferred-intent-woopay branch July 18, 2023 10:39
@timur27 timur27 restored the feature/deferred-intent-woopay branch July 19, 2023 11:53
@frosso frosso deleted the feature/deferred-intent-woopay branch July 19, 2023 13:13
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.

New deferred intent UPE compatibility with WooPay
3 participants