diff --git a/.gitignore b/.gitignore index 27f4d4fc..e9225ed7 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ metadata/ *.p12 **/dw.js **/dw.json +**/dw.json.* .env # avoid publishing translation config diff --git a/cartridges/int_alma/cartridge/scripts/helpers/almaCheckoutHelper.js b/cartridges/int_alma/cartridge/scripts/helpers/almaCheckoutHelper.js index 198538e9..926bf995 100644 --- a/cartridges/int_alma/cartridge/scripts/helpers/almaCheckoutHelper.js +++ b/cartridges/int_alma/cartridge/scripts/helpers/almaCheckoutHelper.js @@ -6,6 +6,7 @@ var isOnShipmentPaymentEnabled = require('*/cartridge/scripts/helpers/almaOnShip var PaymentMgr = require('dw/order/PaymentMgr'); var almaConfigHelper = require('*/cartridge/scripts/helpers/almaConfigHelper'); var almaPaymentHelper = require('*/cartridge/scripts/helpers/almaPaymentHelper'); +var almaHelpers = require('*/cartridge/scripts/helpers/almaHelpers'); var ALMA_PNX_ID = 'ALMA_PNX'; var ALMA_CREDIT_ID = 'ALMA_CREDIT'; @@ -212,6 +213,22 @@ function getPlanPaymentMethodID(plan) { return paymentMethodId; } +/** + * Format Alma mode data to fit in Checkout view data + * @returns {Object} Alma mode data + * - isTest: boolean true if Alma mode is TEST + * - labels: object with title and description for translations + */ +function getFormattedAlmaModeData() { + return { + isTest: almaHelpers.getMode() === 'TEST', + labels: { + title: Resource.msg('alma.test.mode.warn.title', 'alma', null), + description: Resource.msg('alma.test.mode.warn.description', 'alma', null) + } + }; +} + /** * Format plan data to fit in Checkout view data * @param {Object} plan any alma plan @@ -220,46 +237,11 @@ function getPlanPaymentMethodID(plan) { */ function formatPlanForCheckout(plan, currencyCode) { var formatPlan = {}; - if (plan.installments_count < 5 && planIsActivated(PaymentMgr.getPaymentMethod(ALMA_PNX_ID), plan)) { - formatPlan = { - in_page: isAvailableForInpage(plan.installments_count) && almaConfigHelper.isInpageActivated(), - selector: getSelectorNameFromPlan(plan), - installments_count: plan.installments_count, - deferred_days: plan.deferred_days, - purchase_amount: plan.purchase_amount, - customer_fee: plan.customer_fee, - payment_plan: plan.payment_plan, - properties: getPropertiesForPlan(plan, currencyCode), - payment_method: getPlanPaymentMethodID(plan) - }; - } - if (plan.installments_count >= 5 && planIsActivated(PaymentMgr.getPaymentMethod(ALMA_CREDIT_ID), plan)) { - formatPlan = { - in_page: isAvailableForInpage(plan.installments_count) && almaConfigHelper.isInpageActivated(), - selector: getSelectorNameFromPlan(plan), - installments_count: plan.installments_count, - deferred_days: plan.deferred_days, - purchase_amount: plan.purchase_amount, - customer_fee: plan.customer_fee, - payment_plan: plan.payment_plan, - properties: getPropertiesForPlan(plan, currencyCode), - payment_method: getPlanPaymentMethodID(plan) - }; - } - if (plan.deferred_days > 0 && planIsActivated(PaymentMgr.getPaymentMethod(ALMA_DEFERRED_ID), plan)) { - formatPlan = { - in_page: isAvailableForInpage(plan.installments_count) && almaConfigHelper.isInpageActivated(), - selector: getSelectorNameFromPlan(plan), - installments_count: plan.installments_count, - deferred_days: plan.deferred_days, - purchase_amount: plan.purchase_amount, - customer_fee: plan.customer_fee, - payment_plan: plan.payment_plan, - properties: getPropertiesForPlan(plan, currencyCode), - payment_method: getPlanPaymentMethodID(plan) - }; - } - if (plan.installments_count === 1 && plan.deferred_days === 0 && planIsActivated(PaymentMgr.getPaymentMethod(ALMA_PAY_NOW_ID), plan)) { + var ALMA_PNX = plan.installments_count < 5 && planIsActivated(PaymentMgr.getPaymentMethod(ALMA_PNX_ID), plan); + var ALMA_CREDIT = plan.installments_count >= 5 && planIsActivated(PaymentMgr.getPaymentMethod(ALMA_CREDIT_ID), plan); + var ALMA_DEFERRED = plan.deferred_days > 0 && planIsActivated(PaymentMgr.getPaymentMethod(ALMA_DEFERRED_ID), plan); + var ALMA_PAY_NOW = plan.installments_count === 1 && plan.deferred_days === 0 && planIsActivated(PaymentMgr.getPaymentMethod(ALMA_PAY_NOW_ID), plan); + if (ALMA_PNX || ALMA_CREDIT || ALMA_DEFERRED || ALMA_PAY_NOW) { formatPlan = { in_page: isAvailableForInpage(plan.installments_count) && almaConfigHelper.isInpageActivated(), selector: getSelectorNameFromPlan(plan), @@ -269,7 +251,8 @@ function formatPlanForCheckout(plan, currencyCode) { customer_fee: plan.customer_fee, payment_plan: plan.payment_plan, properties: getPropertiesForPlan(plan, currencyCode), - payment_method: getPlanPaymentMethodID(plan) + payment_method: getPlanPaymentMethodID(plan), + alma_mode: getFormattedAlmaModeData() }; } return formatPlan; diff --git a/cartridges/int_alma/cartridge/scripts/helpers/almaPlanHelper.js b/cartridges/int_alma/cartridge/scripts/helpers/almaPlanHelper.js index 28f92cf3..c6982d05 100644 --- a/cartridges/int_alma/cartridge/scripts/helpers/almaPlanHelper.js +++ b/cartridges/int_alma/cartridge/scripts/helpers/almaPlanHelper.js @@ -171,6 +171,7 @@ function buildEligiblePlans(purchaseAmount, feePlans, locale, currentBasket, pla plans[planEligible.payment_method][planEligible.selector].payment_plans = planEligible.payment_plan; plans[planEligible.payment_method][planEligible.selector].properties = planEligible.properties; plans[planEligible.payment_method][planEligible.selector].in_page = planEligible.in_page; + plans[planEligible.payment_method][planEligible.selector].alma_mode = planEligible.alma_mode; }); return plans; diff --git a/cartridges/int_alma/cartridge/static/default/css/almaContent.css b/cartridges/int_alma/cartridge/static/default/css/almaContent.css index 7ca64083..d5e307de 100644 --- a/cartridges/int_alma/cartridge/static/default/css/almaContent.css +++ b/cartridges/int_alma/cartridge/static/default/css/almaContent.css @@ -101,3 +101,14 @@ transform: rotate(360deg); } } + +.alma-test-mode { + background-color: #FFF5CC; + padding: 24px; + border-radius: 20px; + font-size: small; + display: flex; + flex-direction: row; + gap: 16px; + align-items: flex-start; +} diff --git a/cartridges/int_alma/cartridge/static/default/images/warning.svg b/cartridges/int_alma/cartridge/static/default/images/warning.svg new file mode 100644 index 00000000..18f64dcd --- /dev/null +++ b/cartridges/int_alma/cartridge/static/default/images/warning.svg @@ -0,0 +1,5 @@ + diff --git a/cartridges/int_alma/cartridge/templates/default/checkout/billing/paymentOptions/almaContent/almaContent.isml b/cartridges/int_alma/cartridge/templates/default/checkout/billing/paymentOptions/almaContent/almaContent.isml index 1d0e2662..98a9b385 100644 --- a/cartridges/int_alma/cartridge/templates/default/checkout/billing/paymentOptions/almaContent/almaContent.isml +++ b/cartridges/int_alma/cartridge/templates/default/checkout/billing/paymentOptions/almaContent/almaContent.isml @@ -46,6 +46,16 @@
+
+
+ ${plan.alma_mode.labels.title}
+
+ ${plan.alma_mode.labels.description}
+
+