Add hash to return url to trigger UPE validation errors #2982
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 anevent.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
Post merge