mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 14:57:26 +08:00
Handle empty acdc fields
This commit is contained in:
parent
af5d33dc78
commit
729251495f
2 changed files with 21 additions and 1 deletions
|
@ -10,6 +10,7 @@ class CreditCardRenderer {
|
||||||
this.spinner = spinner;
|
this.spinner = spinner;
|
||||||
this.cardValid = false;
|
this.cardValid = false;
|
||||||
this.formValid = false;
|
this.formValid = false;
|
||||||
|
this.emptyFields = new Set(['number', 'cvv', 'expirationDate']);
|
||||||
this.currentHostedFieldsInstance = null;
|
this.currentHostedFieldsInstance = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,6 +139,12 @@ class CreditCardRenderer {
|
||||||
this.formValid = formValid;
|
this.formValid = formValid;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
hostedFields.on('empty', (event) => {
|
||||||
|
this.emptyFields.add(event.emittedBy);
|
||||||
|
});
|
||||||
|
hostedFields.on('notEmpty', (event) => {
|
||||||
|
this.emptyFields.delete(event.emittedBy);
|
||||||
|
});
|
||||||
|
|
||||||
show(buttonSelector);
|
show(buttonSelector);
|
||||||
|
|
||||||
|
@ -249,7 +256,16 @@ class CreditCardRenderer {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.spinner.unblock();
|
this.spinner.unblock();
|
||||||
const message = ! this.cardValid ? this.defaultConfig.hosted_fields.labels.card_not_supported : this.defaultConfig.hosted_fields.labels.fields_not_valid;
|
|
||||||
|
let message = this.defaultConfig.labels.error.generic;
|
||||||
|
if (this.emptyFields.size > 0) {
|
||||||
|
message = this.defaultConfig.hosted_fields.labels.fields_empty;
|
||||||
|
} else if (!this.cardValid) {
|
||||||
|
message = this.defaultConfig.hosted_fields.labels.card_not_supported;
|
||||||
|
} else if (!this.formValid) {
|
||||||
|
message = this.defaultConfig.hosted_fields.labels.fields_not_valid;
|
||||||
|
}
|
||||||
|
|
||||||
this.errorHandler.message(message);
|
this.errorHandler.message(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -893,6 +893,10 @@ class SmartButton implements SmartButtonInterface {
|
||||||
'credit_card_number' => '',
|
'credit_card_number' => '',
|
||||||
'cvv' => '',
|
'cvv' => '',
|
||||||
'mm_yy' => __( 'MM/YY', 'woocommerce-paypal-payments' ),
|
'mm_yy' => __( 'MM/YY', 'woocommerce-paypal-payments' ),
|
||||||
|
'fields_empty' => __(
|
||||||
|
'Card payment details are missing. Please fill in all required fields.',
|
||||||
|
'woocommerce-paypal-payments'
|
||||||
|
),
|
||||||
'fields_not_valid' => __(
|
'fields_not_valid' => __(
|
||||||
'Unfortunately, your credit card details are not valid.',
|
'Unfortunately, your credit card details are not valid.',
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue