Ensure cardholder name when submit card fields

This commit is contained in:
dinamiko 2021-11-24 16:09:36 +01:00
parent 2638486331
commit 1e646fa954
2 changed files with 18 additions and 0 deletions

View file

@ -194,6 +194,23 @@ class CreditCardRenderer {
if (contingency !== 'NO_3D_SECURE') {
hostedFieldsData.contingencies = [contingency];
}
if (this.defaultConfig.payer) {
hostedFieldsData.cardholderName = this.defaultConfig.payer.given_name + ' ' + this.defaultConfig.payer.surname;
}
if (!hostedFieldsData.cardholderName) {
const firstName = document.getElementById('foo_billing_first_name') ? document.getElementById('foo_billing_first_name').value : '';
const last = document.getElementById('billing_last_name') ? document.getElementById('billing_last_name').value : '';
if (!firstName || !lastName) {
this.spinner.unblock();
this.errorHandler.message(this.defaultConfig.hosted_fields.labels.cardholder_name_required);
return;
}
hostedFieldsData.cardholderName = firstName + ' ' + lastName;
}
this.currentHostedFieldsInstance.submit(hostedFieldsData).then((payload) => {
payload.orderID = payload.orderId;
this.spinner.unblock();