diff --git a/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/applePayExpressCommon.js b/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/applePayExpressCommon.js index bf1c3b738..2bfc67b59 100644 --- a/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/applePayExpressCommon.js +++ b/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/applePayExpressCommon.js @@ -126,7 +126,7 @@ function selectShippingMethod({ shipmentUUID, ID }, basketId) { }); } -function getShippingMethod(shippingContact, basketId, isExpressPdp) { +function getShippingMethod(shippingContact, basketId) { const request = { paymentMethodType: APPLE_PAY, basketId, @@ -140,11 +140,7 @@ function getShippingMethod(shippingContact, basketId, isExpressPdp) { postalCode: shippingContact.postalCode, }; } - let url = window.shippingMethodsUrl; - if (isExpressPdp) { - url += '?expressPdp=true'; - } - return fetch(url, { + return fetch(window.shippingMethodsUrl, { method: 'POST', headers: { 'Content-Type': 'application/json; charset=utf-8', @@ -154,14 +150,8 @@ function getShippingMethod(shippingContact, basketId, isExpressPdp) { } async function initializeCheckout() { - const paymentMethods = await getPaymentMethods(window.isExpressPdp); + const paymentMethods = await getPaymentMethods(); paymentMethodsResponse = await paymentMethods.json(); - const shippingMethods = await getShippingMethod( - null, - null, - window.isExpressPdp, - ); - shippingMethodsData = await shippingMethods.json(); const applicationInfo = paymentMethodsResponse?.applicationInfo; checkout = await AdyenCheckout({ environment: window.environment, @@ -233,7 +223,7 @@ async function init() { }; await callPaymentFromComponent( - { ...stateData, customer }, + { ...stateData, customer, basketId: temporaryBasketId }, resolveApplePay, reject, ); @@ -266,6 +256,8 @@ async function init() { } else { reject(); } + } else { + resolve(); } }, onShippingMethodSelected: async (resolve, reject, event) => { diff --git a/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/commons/index.js b/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/commons/index.js index 4a32d924f..e9a1c984e 100644 --- a/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/commons/index.js +++ b/src/cartridges/app_adyen_SFRA/cartridge/client/default/js/commons/index.js @@ -25,18 +25,12 @@ module.exports.fetchGiftCards = async function fetchGiftCards() { /** * Makes an ajax call to the controller function GetPaymentMethods */ -module.exports.getPaymentMethods = async function getPaymentMethods( - isExpressPdp, -) { - const request = { - isExpressPdp, - }; +module.exports.getPaymentMethods = async function getPaymentMethods() { return fetch(window.getPaymentMethodsURL, { method: 'POST', headers: { 'Content-Type': 'application/json; charset=utf-8', }, - body: JSON.stringify(request), }); }; diff --git a/src/cartridges/app_adyen_SFRA/cartridge/templates/default/product/components/addToCartButtonExtension.isml b/src/cartridges/app_adyen_SFRA/cartridge/templates/default/product/components/addToCartButtonExtension.isml index 94ddfb3ff..2e52b257b 100644 --- a/src/cartridges/app_adyen_SFRA/cartridge/templates/default/product/components/addToCartButtonExtension.isml +++ b/src/cartridges/app_adyen_SFRA/cartridge/templates/default/product/components/addToCartButtonExtension.isml @@ -9,6 +9,11 @@ window.locale = "${request.locale}"; window.getPaymentMethodsURL = "${URLUtils.https('Adyen-GetPaymentMethods')}"; window.shippingMethodsUrl = "${URLUtils.https('Adyen-ShippingMethods')}"; + window.selectShippingMethodUrl = "${URLUtils.https('Adyen-SelectShippingMethod')}"; + window.paymentsDetailsURL = "${URLUtils.https('Adyen-PaymentsDetails')}"; + window.paymentFromComponentURL = "${URLUtils.https('Adyen-PaymentFromComponent')}"; + window.showConfirmationAction = "${URLUtils.https('Adyen-ShowConfirmationPaymentFromComponent')}"; + window.returnUrl = "${URLUtils.https('Cart-Show')}"; window.createTemporaryBasketUrl = "${URLUtils.https('Adyen-CreateTemporaryBasket')}"; window.isExpressPdp = true; window.isApplePayExpressOnPdpEnabled = "${AdyenConfigs.isApplePayExpressOnPdpEnabled()}"; diff --git a/src/cartridges/int_adyen_SFRA/cartridge/adyen/scripts/expressPayments/createTemporaryBasket.js b/src/cartridges/int_adyen_SFRA/cartridge/adyen/scripts/expressPayments/createTemporaryBasket.js index b2522284f..a95cbcc52 100644 --- a/src/cartridges/int_adyen_SFRA/cartridge/adyen/scripts/expressPayments/createTemporaryBasket.js +++ b/src/cartridges/int_adyen_SFRA/cartridge/adyen/scripts/expressPayments/createTemporaryBasket.js @@ -18,7 +18,6 @@ function createTemporaryBasket(req, res, next) { // Create a new temporary basket const tempBasket = BasketMgr.createTemporaryBasket(); - // AdyenLogs.debug_log(JSON.stringify(req.form['selected-express-product'])); const product = JSON.parse(req.form['selected-express-product']); const productId = product.id; const childProducts = product.bundledProducts || []; diff --git a/src/cartridges/int_adyen_SFRA/cartridge/adyen/scripts/payments/getCheckoutPaymentMethods.js b/src/cartridges/int_adyen_SFRA/cartridge/adyen/scripts/payments/getCheckoutPaymentMethods.js index 444bbb45c..350c34c41 100644 --- a/src/cartridges/int_adyen_SFRA/cartridge/adyen/scripts/payments/getCheckoutPaymentMethods.js +++ b/src/cartridges/int_adyen_SFRA/cartridge/adyen/scripts/payments/getCheckoutPaymentMethods.js @@ -38,7 +38,6 @@ const getRemainingAmount = (giftCardResponse, currency, currentBasket) => { function getCheckoutPaymentMethods(req, res, next) { try { - const { isExpressPdp } = JSON.parse(req.body); const currentBasket = BasketMgr.getCurrentBasket(); const countryCode = getCountryCode(currentBasket, req.locale); const adyenURL = `${AdyenHelper.getLoadingContext()}images/logos/medium/`; @@ -46,16 +45,12 @@ function getCheckoutPaymentMethods(req, res, next) { const currency = currentBasket ? currentBasket.getTotalGrossPrice().currencyCode : session.currency.currencyCode; - let paymentAmount = getRemainingAmount( + const paymentAmount = getRemainingAmount( session.privacy.giftCardResponse, currency, currentBasket, ); - if (isExpressPdp) { - paymentAmount = new dw.value.Money(1000, currency); - } - const paymentMethods = getPaymentMethods.getMethods( paymentAmount, AdyenHelper.getCustomer(req.currentCustomer), diff --git a/src/cartridges/int_adyen_SFRA/cartridge/adyen/scripts/payments/paymentFromComponent.js b/src/cartridges/int_adyen_SFRA/cartridge/adyen/scripts/payments/paymentFromComponent.js index 21f7fa109..d1cbad80c 100644 --- a/src/cartridges/int_adyen_SFRA/cartridge/adyen/scripts/payments/paymentFromComponent.js +++ b/src/cartridges/int_adyen_SFRA/cartridge/adyen/scripts/payments/paymentFromComponent.js @@ -164,11 +164,13 @@ function canSkipSummaryPage(reqDataObj) { * Make a payment from inside a component, skipping the summary page. (paypal, QRcodes, MBWay) */ function paymentFromComponent(req, res, next) { - const reqDataObj = JSON.parse(req.form.data); + const { basketId, ...reqDataObj } = JSON.parse(req.form.data); if (reqDataObj.cancelTransaction) { return handleCancellation(res, next, reqDataObj); } - const currentBasket = BasketMgr.getCurrentBasket(); + const currentBasket = basketId + ? BasketMgr.getTemporaryBasket(basketId) + : BasketMgr.getCurrentBasket(); let paymentInstrument; Transaction.wrap(() => { collections.forEach(currentBasket.getPaymentInstruments(), (item) => {