mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Merge branch 'PCP-3022-v2-fastlane-frontend-improvements' of github.com:woocommerce/woocommerce-paypal-payments into PCP-3058-additional-fastlane-improvements
This commit is contained in:
commit
40de3e1311
3 changed files with 48 additions and 13 deletions
|
@ -161,7 +161,7 @@ return array(
|
|||
'class' => array(),
|
||||
'label' => __( 'Enable this to display the "Name on Card" field for new Fastlane buyers.', 'woocommerce-paypal-payments' ),
|
||||
'screens' => array( State::STATE_ONBOARDED ),
|
||||
'gateway' => array( 'dcc', 'axo' ),
|
||||
'gateway' => array(),
|
||||
'requirements' => array( 'axo' ),
|
||||
),
|
||||
'axo_style_heading' => array(
|
||||
|
|
|
@ -162,6 +162,20 @@ class AxoManager {
|
|||
ev.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
// Listening to status update event
|
||||
document.addEventListener('axo_status_updated', (ev) => {
|
||||
const termsField = document.querySelector("[name='terms-field']");
|
||||
if(termsField) {
|
||||
const status = ev.detail;
|
||||
|
||||
if(status.active && status.validEmail === false && status.hasProfile === false) {
|
||||
termsField.parentElement.style.display = 'none';
|
||||
} else {
|
||||
termsField.parentElement.style.display = 'block';
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
rerender() {
|
||||
|
@ -347,6 +361,8 @@ class AxoManager {
|
|||
|
||||
log('Status updated', JSON.parse(JSON.stringify(this.status)));
|
||||
|
||||
document.dispatchEvent(new CustomEvent("axo_status_updated", {detail: this.status}));
|
||||
|
||||
this.rerender();
|
||||
}
|
||||
|
||||
|
@ -547,13 +563,16 @@ class AxoManager {
|
|||
if (authResponse.authenticationState === 'succeeded') {
|
||||
log(JSON.stringify(authResponse));
|
||||
|
||||
// Add addresses
|
||||
this.setShipping(authResponse.profileData.shippingAddress);
|
||||
this.setBilling({
|
||||
address: authResponse.profileData.card.paymentSource.card.billingAddress,
|
||||
phoneNumber: authResponse.profileData.shippingAddress.phoneNumber.nationalNumber ?? ''
|
||||
});
|
||||
this.setCard(authResponse.profileData.card);
|
||||
|
||||
const billingAddress = authResponse.profileData?.card?.paymentSource?.card?.billingAddress;
|
||||
if(billingAddress) {
|
||||
this.setBilling({
|
||||
address: billingAddress,
|
||||
phoneNumber: authResponse.profileData.shippingAddress.phoneNumber.nationalNumber ?? ''
|
||||
});
|
||||
this.setCard(authResponse.profileData.card);
|
||||
}
|
||||
|
||||
this.setStatus('validEmail', true);
|
||||
this.setStatus('hasProfile', true);
|
||||
|
@ -623,6 +642,8 @@ class AxoManager {
|
|||
this.shippingView.toSubmitData(data);
|
||||
this.cardView.toSubmitData(data);
|
||||
|
||||
this.ensureBillingPhoneNumber(data);
|
||||
|
||||
this.submit(this.data.card.id, data);
|
||||
|
||||
} else { // Gary flow
|
||||
|
@ -642,10 +663,11 @@ class AxoManager {
|
|||
}
|
||||
|
||||
cardComponentData() {
|
||||
let fields = {};
|
||||
if(this.axoConfig.name_on_card === '1') {
|
||||
fields.cardholderName = {};
|
||||
}
|
||||
const fields = {
|
||||
cardholderName: {
|
||||
enabled: true
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
fields: fields,
|
||||
|
@ -767,6 +789,20 @@ class AxoManager {
|
|||
return Array.isArray(obj) ? obj.filter(val => val) : obj;
|
||||
}
|
||||
|
||||
ensureBillingPhoneNumber(data) {
|
||||
if (data.billing_phone === '') {
|
||||
let phone = '';
|
||||
const cc = this.data?.shipping?.phoneNumber?.countryCode;
|
||||
const number = this.data?.shipping?.phoneNumber?.nationalNumber;
|
||||
|
||||
if (cc) {
|
||||
phone = `+${cc} `;
|
||||
}
|
||||
phone += number;
|
||||
|
||||
data.billing_phone = phone;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default AxoManager;
|
||||
|
|
|
@ -45,8 +45,7 @@ class ShippingView {
|
|||
<div>${data.value('firstName')} ${data.value('lastName')}</div>
|
||||
<div>${data.value('street1')}</div>
|
||||
<div>${data.value('street2')}</div>
|
||||
<div>${data.value('postCode')} ${data.value('city')}</div>
|
||||
<div>${valueOfSelect('#billing_state', data.value('stateCode'))}</div>
|
||||
<div>${data.value('city')}, ${valueOfSelect('#billing_state', data.value('stateCode'))} ${data.value('postCode')} </div>
|
||||
<div>${valueOfSelect('#billing_country', data.value('countryCode'))}</div>
|
||||
<div>${data.value('phone')}</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue