-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ECP-9559] Create an abstract method renderer for Oney/Facilypay vari…
…ants (#2815) Co-authored-by: Can Demiralp <[email protected]>
- Loading branch information
1 parent
0431f3b
commit 720324e
Showing
3 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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( | ||
[ | ||
|
80 changes: 80 additions & 0 deletions
80
view/frontend/web/js/view/payment/method-renderer/adyen-facilypay-method.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
}) | ||
} | ||
); |