Skip to content

Commit

Permalink
fix: c2p customer email is set from basket (#1178)
Browse files Browse the repository at this point in the history
  • Loading branch information
zenit2001 authored Oct 3, 2024
1 parent 6545aa5 commit 7aaca5c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ beforeEach(() => {
querySelector = document.querySelector;
window.Configuration = { environment: 'TEST' };
window.klarnaWidgetEnabled = true;
window.merchantAccount = 'test_merchant';
window.customerEmail = '[email protected]';
store.checkoutConfiguration = {};
setCheckoutConfiguration()
card = getCardConfig();
Expand All @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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};
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -299,7 +300,6 @@ let adyenHelperObj = {
},

getBasketAmount() {
const BasketMgr = require('dw/order/BasketMgr');
const currentBasket = BasketMgr.getCurrentBasket();
if(!currentBasket) {
return;
Expand All @@ -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 = [];
Expand Down

0 comments on commit 7aaca5c

Please sign in to comment.