Ensure input element exist before getting value

This commit is contained in:
Emili Castells Guasch 2023-12-18 11:33:03 +01:00
parent 886a6808b4
commit d68dc62160

View file

@ -91,8 +91,8 @@ class CardFieldsRenderer {
this.spinner.block(); this.spinner.block();
this.errorHandler.clear(); this.errorHandler.clear();
const paymentToken = document.querySelector('input[name="wc-ppcp-credit-card-gateway-payment-token"]:checked').value const paymentToken = document.querySelector('input[name="wc-ppcp-credit-card-gateway-payment-token"]:checked')?.value
if(paymentToken !== 'new') { if(paymentToken && paymentToken !== 'new') {
fetch(this.defaultConfig.ajax.capture_card_payment.endpoint, { fetch(this.defaultConfig.ajax.capture_card_payment.endpoint, {
method: 'POST', method: 'POST',
credentials: 'same-origin', credentials: 'same-origin',