From f487a06e31a0d945c0c27aa791de47cc526e3de5 Mon Sep 17 00:00:00 2001
From: PJaneta
Date: Wed, 4 Sep 2024 11:55:21 +0200
Subject: [PATCH] AD-294 Implement Multiple Small Improvements in v12 Adyen
Integration Modules - merchant account strategy example fix
---
.../CountryAdyenMerchantAccountStrategy.java | 20 +++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/examples/adyenmultiplemerchantexample/src/com/adyen/commerce/strategy/CountryAdyenMerchantAccountStrategy.java b/examples/adyenmultiplemerchantexample/src/com/adyen/commerce/strategy/CountryAdyenMerchantAccountStrategy.java
index ab7fca61..e9e14e8c 100644
--- a/examples/adyenmultiplemerchantexample/src/com/adyen/commerce/strategy/CountryAdyenMerchantAccountStrategy.java
+++ b/examples/adyenmultiplemerchantexample/src/com/adyen/commerce/strategy/CountryAdyenMerchantAccountStrategy.java
@@ -22,11 +22,17 @@ public class CountryAdyenMerchantAccountStrategy implements AdyenMerchantAccount
@Override
public String getWebMerchantAccount() {
BaseStoreModel currentBaseStore = baseStoreService.getCurrentBaseStore();
+
+ return getWebMerchantAccount(currentBaseStore);
+ }
+
+ @Override
+ public String getWebMerchantAccount(BaseStoreModel baseStore) {
CartModel sessionCart = cartService.getSessionCart();
AddressModel deliveryAddress = sessionCart.getDeliveryAddress();
if (deliveryAddress != null) {
- Optional merchantConfigModel = currentBaseStore.getAdyenMerchantConfig().stream().filter(amc ->
+ Optional merchantConfigModel = baseStore.getAdyenMerchantConfig().stream().filter(amc ->
AdyenMerchantAccountType.WEB.equals(amc.getAdyenMerchantType()))
.filter(amc -> StringUtils.equalsIgnoreCase(amc.getCountry().getIsocode(), deliveryAddress.getCountry().getIsocode()))
.findFirst();
@@ -38,17 +44,23 @@ public String getWebMerchantAccount() {
LOG.warn("No WEB merchant config, returning one from adyenMerchantAccount");
- return currentBaseStore.getAdyenMerchantAccount();
+ return baseStore.getAdyenMerchantAccount();
}
@Override
public String getPosMerchantAccount() {
BaseStoreModel currentBaseStore = baseStoreService.getCurrentBaseStore();
+
+ return getPosMerchantAccount(currentBaseStore);
+ }
+
+ @Override
+ public String getPosMerchantAccount(BaseStoreModel baseStore) {
CartModel sessionCart = cartService.getSessionCart();
AddressModel deliveryAddress = sessionCart.getDeliveryAddress();
if (deliveryAddress != null) {
- Optional merchantConfigModel = currentBaseStore.getAdyenMerchantConfig().stream().filter(amc ->
+ Optional merchantConfigModel = baseStore.getAdyenMerchantConfig().stream().filter(amc ->
AdyenMerchantAccountType.POS.equals(amc.getAdyenMerchantType()))
.filter(amc -> StringUtils.equalsIgnoreCase(amc.getCountry().getIsocode(), deliveryAddress.getCountry().getIsocode()))
.findFirst();
@@ -59,7 +71,7 @@ public String getPosMerchantAccount() {
}
LOG.warn("No POS merchant config, returning one from adyenMerchantAccount");
- return currentBaseStore.getAdyenPosMerchantAccount();
+ return baseStore.getAdyenPosMerchantAccount();
}
public void setBaseStoreService(BaseStoreService baseStoreService) {