diff --git a/modules/ppcp-axo/resources/js/AxoManager.js b/modules/ppcp-axo/resources/js/AxoManager.js index 140dea944..6fbdb8d73 100644 --- a/modules/ppcp-axo/resources/js/AxoManager.js +++ b/modules/ppcp-axo/resources/js/AxoManager.js @@ -6,6 +6,7 @@ import BillingView from "./Views/BillingView"; import CardView from "./Views/CardView"; import PayPalInsights from "./Insights/PayPalInsights"; import {disable,enable} from "../../../ppcp-button/resources/js/modules/Helper/ButtonDisabler"; +import {getCurrentPaymentMethod} from "../../../ppcp-button/resources/js/modules/Helper/CheckoutMethodState"; class AxoManager { @@ -154,6 +155,13 @@ class AxoManager { this.cardView.refresh(); }); + // Prevents sending checkout form when pressing Enter key on input field + // and triggers customer lookup + this.$('form.woocommerce-checkout input').on('keydown', async (ev) => { + if(ev.key === 'Enter' && getCurrentPaymentMethod() === 'ppcp-axo-gateway' ) { + ev.preventDefault(); + } + }); } rerender() { @@ -222,6 +230,8 @@ class AxoManager { } if (scenario.axoProfileViews) { + this.el.billingAddressContainer.hide(); + this.shippingView.activate(); this.billingView.activate(); this.cardView.activate(); @@ -520,6 +530,10 @@ class AxoManager { page_type: 'checkout' }); + await this.lookupCustomerByEmail(); + } + + async lookupCustomerByEmail() { const lookupResponse = await this.fastlane.identity.lookupCustomerByEmail(this.emailInput.value); if (lookupResponse.customerContextId) { @@ -537,7 +551,8 @@ class AxoManager { // Add addresses this.setShipping(authResponse.profileData.shippingAddress); this.setBilling({ - address: authResponse.profileData.card.paymentSource.card.billingAddress + address: authResponse.profileData.card.paymentSource.card.billingAddress, + phoneNumber: authResponse.profileData.shippingAddress.phoneNumber.nationalNumber ?? '' }); this.setCard(authResponse.profileData.card); diff --git a/modules/ppcp-axo/resources/js/Components/DomElement.js b/modules/ppcp-axo/resources/js/Components/DomElement.js index 8e789d485..30cadcb2a 100644 --- a/modules/ppcp-axo/resources/js/Components/DomElement.js +++ b/modules/ppcp-axo/resources/js/Components/DomElement.js @@ -1,5 +1,3 @@ -import {setVisible} from "../../../../ppcp-button/resources/js/modules/Helper/Hiding"; - class DomElement { constructor(config) { diff --git a/modules/ppcp-axo/resources/js/Connection/Fastlane.js b/modules/ppcp-axo/resources/js/Connection/Fastlane.js index 9f2993081..8e1c76949 100644 --- a/modules/ppcp-axo/resources/js/Connection/Fastlane.js +++ b/modules/ppcp-axo/resources/js/Connection/Fastlane.js @@ -18,6 +18,7 @@ class Fastlane { resolve(); }) .catch((error) => { + console.error(error) reject(); }); }); diff --git a/modules/ppcp-axo/resources/js/Views/BillingView.js b/modules/ppcp-axo/resources/js/Views/BillingView.js index e7d517f62..aba44afcf 100644 --- a/modules/ppcp-axo/resources/js/Views/BillingView.js +++ b/modules/ppcp-axo/resources/js/Views/BillingView.js @@ -90,6 +90,10 @@ class BillingView { company: { 'selector': '#billing_company_field', 'valuePath': null, + }, + phone: { + 'selector': '#billing_phone_field', + 'valuePath': 'billing.phoneNumber' } } }); diff --git a/modules/ppcp-axo/resources/js/Views/ShippingView.js b/modules/ppcp-axo/resources/js/Views/ShippingView.js index cc9550951..4f0a18f8d 100644 --- a/modules/ppcp-axo/resources/js/Views/ShippingView.js +++ b/modules/ppcp-axo/resources/js/Views/ShippingView.js @@ -40,6 +40,7 @@ class ShippingView {

Shipping

Edit +
${data.value('email')}
${data.value('company')}
${data.value('firstName')} ${data.value('lastName')}
${data.value('street1')}
@@ -52,6 +53,9 @@ class ShippingView { `; }, fields: { + email: { + 'valuePath': 'email', + }, firstName: { 'key': 'firstName', 'selector': '#shipping_first_name_field', diff --git a/modules/ppcp-button/resources/js/modules/Helper/ScriptLoading.js b/modules/ppcp-button/resources/js/modules/Helper/ScriptLoading.js index c2b7a6dda..dce3136c8 100644 --- a/modules/ppcp-button/resources/js/modules/Helper/ScriptLoading.js +++ b/modules/ppcp-button/resources/js/modules/Helper/ScriptLoading.js @@ -3,6 +3,7 @@ import {loadScript} from "@paypal/paypal-js"; import widgetBuilder from "../Renderer/WidgetBuilder"; import merge from "deepmerge"; import {keysToCamelCase} from "./Utils"; +import {getCurrentPaymentMethod} from "./CheckoutMethodState"; // This component may be used by multiple modules. This assures that options are shared between all instances. let options = window.ppcpWidgetBuilder = window.ppcpWidgetBuilder || { @@ -75,7 +76,7 @@ export const loadPaypalScript = (config, onLoaded, onError = null) => { // Adds data-user-id-token to script options. const userIdToken = config?.save_payment_methods?.id_token; - if(userIdToken) { + if(userIdToken && !sdkClientToken) { scriptOptions['data-user-id-token'] = userIdToken; }