Skip to content

Commit

Permalink
[ECP-9559] Create an abstract method renderer for Oney/Facilypay vari…
Browse files Browse the repository at this point in the history
…ants (#2815)

Co-authored-by: Can Demiralp <[email protected]>
  • Loading branch information
candemiralp and Can Demiralp authored Nov 26, 2024
1 parent 0431f3b commit 720324e
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
4 changes: 4 additions & 0 deletions etc/frontend/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@
<item name="adyen_applepay" xsi:type="string">Adyen_Payment/js/view/payment/method-renderer/adyen-applepay-method</item>
<item name="adyen_boleto" xsi:type="string">Adyen_Payment/js/view/payment/method-renderer/adyen-boleto-method</item>
<item name="adyen_facilypay_3x" xsi:type="string">Adyen_Payment/js/view/payment/method-renderer/adyen-facilypay-3x-method</item>
<item name="adyen_facilypay_4x" xsi:type="string">Adyen_Payment/js/view/payment/method-renderer/adyen-facilypay-method</item>
<item name="adyen_facilypay_6x" xsi:type="string">Adyen_Payment/js/view/payment/method-renderer/adyen-facilypay-method</item>
<item name="adyen_facilypay_10x" xsi:type="string">Adyen_Payment/js/view/payment/method-renderer/adyen-facilypay-method</item>
<item name="adyen_facilypay_12x" xsi:type="string">Adyen_Payment/js/view/payment/method-renderer/adyen-facilypay-method</item>
<item name="adyen_googlepay" xsi:type="string">Adyen_Payment/js/view/payment/method-renderer/adyen-googlepay-method</item>
<item name="adyen_paypal" xsi:type="string">Adyen_Payment/js/view/payment/method-renderer/adyen-paypal-method</item>
<item name="adyen_giftcard" xsi:type="string">Adyen_Payment/js/view/payment/method-renderer/adyen-giftcard-method</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
* See LICENSE.txt for license details.
*
* Author: Adyen <[email protected]>
*
* @deprecated This file will be removed on V10. Use `adyen-facilypay-method.js` instead.
*
*/
define(
[
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
*/
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;
}
})
}
);

0 comments on commit 720324e

Please sign in to comment.