Skip to content

Commit

Permalink
Merge pull request #442 from Adyen/feature/AD-294
Browse files Browse the repository at this point in the history
AD-294 Implement Multiple Small Improvements in v12 Adyen Integration…
  • Loading branch information
kpieloch authored Sep 11, 2024
2 parents 3d4987b + f487a06 commit 569c24a
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<AdyenMerchantConfigModel> merchantConfigModel = currentBaseStore.getAdyenMerchantConfig().stream().filter(amc ->
Optional<AdyenMerchantConfigModel> merchantConfigModel = baseStore.getAdyenMerchantConfig().stream().filter(amc ->
AdyenMerchantAccountType.WEB.equals(amc.getAdyenMerchantType()))
.filter(amc -> StringUtils.equalsIgnoreCase(amc.getCountry().getIsocode(), deliveryAddress.getCountry().getIsocode()))
.findFirst();
Expand All @@ -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<AdyenMerchantConfigModel> merchantConfigModel = currentBaseStore.getAdyenMerchantConfig().stream().filter(amc ->
Optional<AdyenMerchantConfigModel> merchantConfigModel = baseStore.getAdyenMerchantConfig().stream().filter(amc ->
AdyenMerchantAccountType.POS.equals(amc.getAdyenMerchantType()))
.filter(amc -> StringUtils.equalsIgnoreCase(amc.getCountry().getIsocode(), deliveryAddress.getCountry().getIsocode()))
.findFirst();
Expand All @@ -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) {
Expand Down

0 comments on commit 569c24a

Please sign in to comment.