diff --git a/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/adyen_checkout/__tests__/checkoutConfiguration.test.js b/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/adyen_checkout/__tests__/checkoutConfiguration.test.js index 0b766b384..31e2265d4 100644 --- a/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/adyen_checkout/__tests__/checkoutConfiguration.test.js +++ b/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/adyen_checkout/__tests__/checkoutConfiguration.test.js @@ -29,6 +29,8 @@ beforeEach(() => { querySelector = document.querySelector; window.Configuration = { environment: 'TEST' }; window.klarnaWidgetEnabled = true; + window.merchantAccount = 'test_merchant'; + window.customerEmail = 'test@email.com'; store.checkoutConfiguration = {}; setCheckoutConfiguration() card = getCardConfig(); @@ -49,6 +51,8 @@ describe('Checkout Configuration', () => { const data = { paymentMethod: { type: 'scheme' } }; card.onChange({ isValid: true, data }, { props: { holderName: 'test' } }); expect(store.selectedPayment.isValid).toBeTruthy(); + expect(card.clickToPayConfiguration.shopperEmail).toBe(window.customerEmail); + expect(card.clickToPayConfiguration.merchantDisplayName).toBe(window.merchantAccount); }); it('handles onFieldValid', () => { diff --git a/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/adyen_checkout/checkoutConfiguration.js b/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/adyen_checkout/checkoutConfiguration.js index 051950762..7ec8ef2e1 100644 --- a/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/adyen_checkout/checkoutConfiguration.js +++ b/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/adyen_checkout/checkoutConfiguration.js @@ -202,9 +202,8 @@ function getGiftCardConfig() { async: false, success: (data) => { giftcardBalance = data.balance; - document.querySelector( - 'button[value="submit-payment"]', - ).disabled = false; + document.querySelector('button[value="submit-payment"]').disabled = + false; if (data.resultCode === constants.SUCCESS) { const { giftCardsInfoMessageContainer, @@ -230,9 +229,8 @@ function getGiftCardConfig() { initialPartialObject.totalDiscountedAmount; }); - document.querySelector( - 'button[value="submit-payment"]', - ).disabled = true; + document.querySelector('button[value="submit-payment"]').disabled = + true; giftCardsInfoMessageContainer.innerHTML = ''; giftCardsInfoMessageContainer.classList.remove( 'gift-cards-info-message-container', diff --git a/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/adyen_checkout/renderGiftcardComponent.js b/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/adyen_checkout/renderGiftcardComponent.js index dc16d6139..e2f73a19b 100644 --- a/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/adyen_checkout/renderGiftcardComponent.js +++ b/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/adyen_checkout/renderGiftcardComponent.js @@ -98,9 +98,8 @@ function removeGiftCards() { giftCardsInfoMessageContainer.classList.remove( 'gift-cards-info-message-container', ); - document.querySelector( - 'button[value="submit-payment"]', - ).disabled = false; + document.querySelector('button[value="submit-payment"]').disabled = + false; if (res.resultCode === constants.RECEIVED) { document diff --git a/src/cartridges/app_adyen_SFRA/cartridge/templates/default/checkout/billing/adyenComponentForm.isml b/src/cartridges/app_adyen_SFRA/cartridge/templates/default/checkout/billing/adyenComponentForm.isml index eeb98c844..276a6f889 100644 --- a/src/cartridges/app_adyen_SFRA/cartridge/templates/default/checkout/billing/adyenComponentForm.isml +++ b/src/cartridges/app_adyen_SFRA/cartridge/templates/default/checkout/billing/adyenComponentForm.isml @@ -59,7 +59,7 @@ window.installments = '${pdict.adyen.installments}'; window.googleMerchantID = '${pdict.adyen.googleMerchantID}'; window.merchantAccount = '${pdict.adyen.merchantAccount}'; - window.customerEmail = '${customer && customer.profile && customer.profile.email ? customer.profile.email : ''}'; + window.customerEmail = '${pdict.AdyenHelper.getCustomerEmail()}'; var showStoreDetails = ${customer.authenticated && adyenRecurringPaymentsEnabled}; diff --git a/src/cartridges/int_adyen_SFRA/cartridge/adyen/utils/adyenHelper.js b/src/cartridges/int_adyen_SFRA/cartridge/adyen/utils/adyenHelper.js index 60ef9bd07..45e6b4ca8 100644 --- a/src/cartridges/int_adyen_SFRA/cartridge/adyen/utils/adyenHelper.js +++ b/src/cartridges/int_adyen_SFRA/cartridge/adyen/utils/adyenHelper.js @@ -31,6 +31,7 @@ const StringUtils = require('dw/util/StringUtils'); const Money = require('dw/value/Money'); const TaxMgr = require('dw/order/TaxMgr'); const ShippingLocation = require('dw/order/ShippingLocation'); +const BasketMgr = require('dw/order/BasketMgr'); //script includes const ShippingMethodModel = require('*/cartridge/models/shipping/shippingMethod'); const collections = require('*/cartridge/scripts/util/collections'); @@ -299,7 +300,6 @@ let adyenHelperObj = { }, getBasketAmount() { - const BasketMgr = require('dw/order/BasketMgr'); const currentBasket = BasketMgr.getCurrentBasket(); if(!currentBasket) { return; @@ -313,6 +313,11 @@ let adyenHelperObj = { return JSON.stringify(amount); }, + getCustomerEmail() { + const currentBasket = BasketMgr.getCurrentBasket(); + return currentBasket ? currentBasket.customerEmail : ''; + }, + // returns an array containing the donation amounts configured in the custom preferences for Adyen Giving getDonationAmounts() { let returnValue = [];