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

Fix PayPal popup infinite loading spinner if T&Cs are not checked #2659

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Axel29
Copy link

@Axel29 Axel29 commented Jun 21, 2024

Description

Add onInit and onClick functions to the configuration object in order to maange the PayPal Buttons state (enabled / disabled) depending on the checkout agreements checkbox state.

Without these functions, if the form is not valid (checkbox unchecked) and the user clicks on the PayPal button, the popup will be opened with an infinite loading spinner, and even if the customer closes the popup, checks the checkbox and clicks again on the PayPal button, the popup will not work anymore, until the page is reloaded.

Tested scenarios

  1. Enable Terms and Conditions in Magento's configuration (Stores > Configuration > Sales > Checkout > Checkout Options > Enable Terms and Conditions).
  2. Create Terms and Conditions in the administration (Stores > Settings > Terms and Conditions) and set them as required.
  3. Enable PayPal in Adyen
  4. Go to the checkout
  5. Click on the PayPal button that should open a PayPal popup without clicking the Terms and Conditions

Expected result

  • PayPal popup should not be opened
  • The form should display an error message bellow the terms and conditions
  • After checking these terms and conditions, the user should be able to open the PayPal popup by clicking on the CTA again

Fixes #2613

… checked

If the checkout form is not valid and the user clicks on the PayPal button, the popup will be opened with an infinite loading spinner.

Event if the customer closes the popup, checks the checkbox and clicks again on the PayPal button, the popup will not work anymore, until the page is reloaded.
@candemiralp
Copy link
Member

Hello @Axel29,

Thank you for your contribution. I've tested the implementation and have some comments.

PayPal_TC_infinite_loader.mp4

Implementation works fine and solves the issue if the user arrives on payment method selection page from shipping address and method selection page. (See the first part of the video). However, if the user refreshes the page on the payment method selection page, a race condition occurs. After the refresh, the code is executed before the page is loaded. T&C checkbox is mounted to the checkout after loading the payment method. So, the selector for the input box is always null (See the second part of the video).

Do you have any recommendation for solving this race condition?

Best Regards,
Can

* closes the popup, checks the checkbox and clicks again on the PayPal button, the popup will not work
* anymore, until the page is reloaded.
*/
let checkoutAgreementsInput = document.querySelector('.checkout-agreement input');
Copy link
Member

Choose a reason for hiding this comment

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

Race condition occurs if the payment method page is refreshed. See my comment here.

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.

[ECP-9098] PayPal not working when T&C's are not checked
2 participants