Prevent Enter key submit for our non-standard button gateways

Otherwise pressing Enter triggers WC order process without e.g. completing payment via paypal popup, and results in failure with confusing error message.
This commit is contained in:
Alex P 2022-11-14 10:17:26 +02:00
parent 7ffbb5e159
commit edea76c9e4

View file

@ -30,6 +30,16 @@ const bootstrap = () => {
const freeTrialHandler = new FreeTrialHandler(PayPalCommerceGateway, spinner, errorHandler);
jQuery('form.woocommerce-checkout input').on('keydown', e => {
if (e.key === 'Enter' && [
PaymentMethods.PAYPAL,
PaymentMethods.CARDS,
PaymentMethods.CARD_BUTTON,
].includes(getCurrentPaymentMethod())) {
e.preventDefault();
}
});
const onSmartButtonClick = (data, actions) => {
window.ppcpFundingSource = data.fundingSource;