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

Assign callbacks to gateway-specific actions in the abstract checkout class to avoid unnecessary duplication #5246

Merged

Conversation

timur27
Copy link
Contributor

@timur27 timur27 commented Dec 5, 2022

Fixes #5117

Changes proposed in this Pull Request

This PR:

  1. Fixes the duplicated notices bug while saving the SEPA payment method (Multiple UPE - Duplicate notices when saving SEPA methods #5117)
  2. Adds callbacks to hooks in the checkout class instead of UPE gateway class which is now initialized multiple times per each payment method. This allows us to avoid the situation when one callback is added to a hook multiple times, whereas only one addition is needed
  3. Aligns the setup/payment intents removal methods to remove all the payment intents since we now are invoking them from the checkout class

Testing instructions 🔴 🟢

1️⃣ Test hook invocation, responsible for removing setup intent from the session.

💡 Setup intent is removed when loading the payment methods page in My account.

  1. Go to My account -> Payment methods and add a new SEPA payment method.
  2. After adding and redirected back to the tokens list, go and add another SEPA payment method and ensure that there are no failures while adding the payment method. When there are problems with removing the setup intent, errors with the message You cannot update this SetupIntent because it has already succeeded. usually appear. In this step, we'd like to confirm that we don't see such errors.
  3. Repeat steps 1-2 with the legacy card.
2️⃣ Test payment intent removal callback invocation

Confirm there are no errors in the two following use cases (does not matter if you save the payment method or not):

  1. Use shortcode checkout to buy any product with a card twice in a row.
  2. Use shortcode checkout to buy any product with the SEPA payment method twice in a row.
3️⃣ Test fixed duplicated notices when saving SEPA
  1. Go to My account -> Payment methods and add a new SEPA payment method.
  2. Ensure that there is only one Payment method successfully added. notice after being redirected to the payment method list.
4️⃣ Test if appearance callbacks are invoked

To check if save_upe_appearance_ajax and clear_upe_appearance_transient callbacks are invoked:

  1. Set debug breakpoints in save_upe_appearance_ajax() and clear_upe_appearance_transient() methods.
  2. Change the theme in the admin panel under Appearance and ensure that the clear_upe_appearance_transient method is invoked and the debugger stops at the breakpoint. In my case, I switched from Storefront to Twenty Twenty-Two.
  3. Go to the store, add a product and proceed to the checkout page.
  4. On the shortcode checkout page loading, confirm that the save_upe_appearance_ajax() method is invoked and debugger stops at the breakpoint.

  • 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

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2022

Size Change: 0 B

Total Size: 1.09 MB

ℹ️ View Unchanged
Filename Size
release/woocommerce-payments/assets/css/admin.css 913 B
release/woocommerce-payments/assets/css/success.css 401 B
release/woocommerce-payments/dist/blocks-checkout.css 2.13 kB
release/woocommerce-payments/dist/blocks-checkout.js 23.8 kB
release/woocommerce-payments/dist/checkout.css 2.21 kB
release/woocommerce-payments/dist/checkout.js 14.7 kB
release/woocommerce-payments/dist/fp_agent.js 14 kB
release/woocommerce-payments/dist/index.css 36.1 kB
release/woocommerce-payments/dist/index.js 307 kB
release/woocommerce-payments/dist/multi-currency-analytics.js 771 B
release/woocommerce-payments/dist/multi-currency-switcher-block.js 56.1 kB
release/woocommerce-payments/dist/multi-currency.css 14.7 kB
release/woocommerce-payments/dist/multi-currency.js 72.5 kB
release/woocommerce-payments/dist/order.css 248 B
release/woocommerce-payments/dist/order.js 12.4 kB
release/woocommerce-payments/dist/payment-gateways.css 1.2 kB
release/woocommerce-payments/dist/payment-gateways.js 47 kB
release/woocommerce-payments/dist/payment-request.js 11.7 kB
release/woocommerce-payments/dist/platform-checkout-express-button.js 12.7 kB
release/woocommerce-payments/dist/platform-checkout.css 3.73 kB
release/woocommerce-payments/dist/platform-checkout.js 70.8 kB
release/woocommerce-payments/dist/settings.css 47.4 kB
release/woocommerce-payments/dist/settings.js 111 kB
release/woocommerce-payments/dist/subscription-edit-page.js 392 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.css 7.18 kB
release/woocommerce-payments/dist/subscription-product-onboarding-modal.js 12.6 kB
release/woocommerce-payments/dist/subscription-product-onboarding-toast.js 434 B
release/woocommerce-payments/dist/subscriptions-empty-state.css 298 B
release/woocommerce-payments/dist/subscriptions-empty-state.js 44.1 kB
release/woocommerce-payments/dist/tos.css 236 B
release/woocommerce-payments/dist/tos.js 15.5 kB
release/woocommerce-payments/dist/upe_checkout.css 2.21 kB
release/woocommerce-payments/dist/upe_checkout.js 20 kB
release/woocommerce-payments/dist/upe-blocks-checkout.css 2.13 kB
release/woocommerce-payments/dist/upe-blocks-checkout.js 26.2 kB
release/woocommerce-payments/includes/platform-checkout/assets/css/platform-checkout-express-button.css 247 B
release/woocommerce-payments/includes/subscriptions/assets/css/plugin-page.css 633 B
release/woocommerce-payments/includes/subscriptions/assets/js/plugin-page.js 355 B
release/woocommerce-payments/vendor/automattic/jetpack-admin-ui/src/css/jetpack-icon.css 224 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-identity-crisis/babel.config.js 160 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.css 2.27 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.js 13.3 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.rtl.css 2.27 kB
release/woocommerce-payments/vendor/automattic/jetpack-tracking/src/js/tracks-ajax.js 789 B
release/woocommerce-payments/vendor/automattic/jetpack-tracking/src/js/tracks-callables.js 925 B
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.43 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 8.97 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.35 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 387 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

@timur27 timur27 marked this pull request as ready for review December 5, 2022 16:21
@timur27 timur27 requested review from a team and mdmoore and removed request for a team December 5, 2022 16:21
Copy link
Member

@mdmoore mdmoore left a comment

Choose a reason for hiding this comment

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

Everything is testing well except adding a card from My Account > Payment Methods in test 1.3, Repeat steps 1-2 with the legacy card.. But I think that's solved in #5237. So everything it looking great here! :shipit:

@timur27 timur27 merged commit 41b72c1 into poc/upe-instances-multiplied Dec 8, 2022
@timur27 timur27 deleted the fix/duplicate-notices-when-saving-sepa branch December 8, 2022 07:07
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