diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index 34576cb77..a5e4a65ee 100755 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -121,6 +121,10 @@ Adyen_Payment/js/view/payment/method-renderer/adyen-applepay-method Adyen_Payment/js/view/payment/method-renderer/adyen-boleto-method Adyen_Payment/js/view/payment/method-renderer/adyen-facilypay-3x-method + Adyen_Payment/js/view/payment/method-renderer/adyen-facilypay-method + Adyen_Payment/js/view/payment/method-renderer/adyen-facilypay-method + Adyen_Payment/js/view/payment/method-renderer/adyen-facilypay-method + Adyen_Payment/js/view/payment/method-renderer/adyen-facilypay-method Adyen_Payment/js/view/payment/method-renderer/adyen-googlepay-method Adyen_Payment/js/view/payment/method-renderer/adyen-paypal-method Adyen_Payment/js/view/payment/method-renderer/adyen-giftcard-method diff --git a/view/frontend/web/js/view/payment/method-renderer/adyen-facilypay-3x-method.js b/view/frontend/web/js/view/payment/method-renderer/adyen-facilypay-3x-method.js index cc4bf208c..11e2d4ef1 100644 --- a/view/frontend/web/js/view/payment/method-renderer/adyen-facilypay-3x-method.js +++ b/view/frontend/web/js/view/payment/method-renderer/adyen-facilypay-3x-method.js @@ -6,6 +6,9 @@ * See LICENSE.txt for license details. * * Author: Adyen + * + * @deprecated This file will be removed on V10. Use `adyen-facilypay-method.js` instead. + * */ define( [ diff --git a/view/frontend/web/js/view/payment/method-renderer/adyen-facilypay-method.js b/view/frontend/web/js/view/payment/method-renderer/adyen-facilypay-method.js new file mode 100644 index 000000000..7eb71c71d --- /dev/null +++ b/view/frontend/web/js/view/payment/method-renderer/adyen-facilypay-method.js @@ -0,0 +1,80 @@ +/** + * + * Adyen Payment module (https://www.adyen.com/) + * + * Copyright (c) 2024 Adyen N.V. (https://www.adyen.com/) + * See LICENSE.txt for license details. + * + * Author: Adyen + */ +define( + [ + 'Magento_Checkout/js/model/quote', + 'Adyen_Payment/js/view/payment/method-renderer/adyen-pm-method', + ], + function( + quote, + adyenPaymentMethod, + ) { + return adyenPaymentMethod.extend({ + initialize: function () { + this._super(); + }, + buildComponentConfiguration: function (paymentMethod, paymentMethodsExtraInfo) { + let baseComponentConfiguration = this._super(); + let self = this; + let formattedShippingAddress = {}; + let formattedBillingAddress = {}; + let shopperDateOfBirth = ''; + let email = {}; + + if (!!customerData.dob){ + shopperDateOfBirth = customerData.dob; + } + + if (!!customerData.email) { + email = customerData.email; + } else if (!!quote.guestEmail) { + email = quote.guestEmail; + }; + + if (!quote.isVirtual() && !!quote.shippingAddress()) { + formattedShippingAddress = self.getFormattedAddress(quote.shippingAddress()); + } + + if (!quote.isVirtual() && !!quote.billingAddress()) { + formattedBillingAddress = self.getFormattedAddress(quote.billingAddress()); + } + + if (formattedShippingAddress) { + baseComponentConfiguration.data.deliveryAddress = { + city: formattedShippingAddress.city, + country: formattedShippingAddress.country, + houseNumberOrName: formattedShippingAddress.houseNumber, + postalCode: formattedShippingAddress.postalCode, + street: formattedShippingAddress.street + } + } + + if (formattedBillingAddress){ + baseComponentConfiguration.data.personalDetails = { + firstName: formattedBillingAddress.firstName, + lastName: formattedBillingAddress.lastName, + telephoneNumber: formattedBillingAddress.telephone, + shopperEmail: email, + dateOfBirth: shopperDateOfBirth, + } + baseComponentConfiguration.data.billingAddress = { + city: formattedBillingAddress.city, + country: formattedBillingAddress.country, + houseNumberOrName: formattedBillingAddress.houseNumber, + postalCode: formattedBillingAddress.postalCode, + street: formattedBillingAddress.street, + } + } + + return baseComponentConfiguration; + } + }) + } +);