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

Add hash to return url to trigger UPE validation errors #2982

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

bborman22
Copy link
Contributor

This issue was discovered in the Stripe plugin implementation of UPE: woocommerce/woocommerce-gateway-stripe#1940

Changes proposed in this Pull Request

Fix UPE Form Validation

With UPE, the field validation doesn't occur until something has been entered in to one of the fields. To capture instances where a user may not have interacted with all the fields and instead just hit submit, we run a sort of "mock" confirmPayment call to trigger the validation. We only run this when we have not received an event.complete from the UPE element. That event only fires once all required fields have been filled in.

There may have been a change the Stripe API that now requires a non-empty value for the confirmParams.return_url. Previously with that value empty the confirm would work and trigger validation, but now it throws an error. This PR adds a hash to that parameter to now avoid the error. This should be a safe workaround as we already know at this point that the confirmation will fail due to the fact that not all fields have been provided.

Testing instructions

  • Start with this branch and UPE enabled with at least CC enabled within UPE.
  • Make sure to the JS has been rebuilt with this change from the PR.
  • As a customer, add a product to the cart and go to checkout. Confirm UPE loads.
  • Without entering any payment information, click the Place Order button.
  • Confirm that error messages are displayed for the invalid fields.
  • Refresh the checkout page.
  • Enter a full CC number, but do not enter any expiration or CVV and click Place Order.
  • Confirm that error messages are displayed for the invalid fields and no console errors are shown.
  • Complete all payment fields and click Place Order.
  • Confirm that the order was successfully placed.
  • Next as a logged in customer visit the My Account > Payment Methods page.
  • Click Add Payment Method button.
  • Run through some of the same tests listed above with empty/partially filled/then fully filled fields and confirm that the proper error messages are displayed and no console errors are shown.

  • Added changelog entry (or does not apply)
  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Post merge

@rashedripon
Copy link

A similar case has been reported here: 27209950-hc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants