mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Merge pull request #385 from woocommerce/PCP-359-customer-details-not-available-i
Ensure hosted fields `cardholderName` is submitted to JavaScript SDK
This commit is contained in:
commit
2d903e19a6
2 changed files with 23 additions and 5 deletions
|
@ -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('billing_first_name') ? document.getElementById('billing_first_name').value : '';
|
||||
const lastName = 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();
|
||||
|
|
|
@ -684,17 +684,18 @@ class SmartButton implements SmartButtonInterface {
|
|||
'wrapper' => '#ppcp-hosted-fields',
|
||||
'mini_cart_wrapper' => '#ppcp-hosted-fields-mini-cart',
|
||||
'labels' => array(
|
||||
'credit_card_number' => '',
|
||||
'cvv' => '',
|
||||
'mm_yy' => __( 'MM/YY', 'woocommerce-paypal-payments' ),
|
||||
'fields_not_valid' => __(
|
||||
'credit_card_number' => '',
|
||||
'cvv' => '',
|
||||
'mm_yy' => __( 'MM/YY', 'woocommerce-paypal-payments' ),
|
||||
'fields_not_valid' => __(
|
||||
'Unfortunately, your credit card details are not valid.',
|
||||
'woocommerce-paypal-payments'
|
||||
),
|
||||
'card_not_supported' => __(
|
||||
'card_not_supported' => __(
|
||||
'Unfortunately, we do not support your credit card.',
|
||||
'woocommerce-paypal-payments'
|
||||
),
|
||||
'cardholder_name_required' => __( 'Cardholder\'s first and last name are required, please fill the checkout form required fields.', 'woocommerce-paypal-payments' ),
|
||||
),
|
||||
'valid_cards' => $this->dcc_applies->valid_cards(),
|
||||
'contingency' => $this->get_3ds_contingency(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue