Skip to content

Commit

Permalink
Merge pull request #432 from Adyen/feature/AD-296
Browse files Browse the repository at this point in the history
AD-296 Enhance Configurability of ExcludedPaymentMethods Attribute
  • Loading branch information
kpieloch authored Sep 3, 2024
2 parents eacc240 + 594cad4 commit 1d65005
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,7 @@
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -163,6 +154,7 @@ public class DefaultAdyenCheckoutFacade implements AdyenCheckoutFacade {
private static final String ES_LOCALE = "es_ES";
private static final String US = "US";
private static final String RECURRING_RECURRING_DETAIL_REFERENCE = "recurring.recurringDetailReference";
private static final String EXCLUDED_PAYMENT_METHODS_CONFIG = "adyen.payment-methods.excluded";

private BaseStoreService baseStoreService;
private SessionService sessionService;
Expand Down Expand Up @@ -706,7 +698,8 @@ public CheckoutConfigDTO getReactCheckoutConfig() throws ApiException {
CartModel cartModel = cartService.getSessionCart();

//to remove unwanted payment methods insert them here
List<String> excludedPaymentMethods = new ArrayList<>();
List<String> excludedPaymentMethods = getExcludedPaymentMethodsFromConfiguration();
LOGGER.info(excludedPaymentMethods.toString());

try {
if (showPos()) {
Expand Down Expand Up @@ -789,6 +782,16 @@ public CheckoutConfigDTO getReactCheckoutConfig() throws ApiException {
.build();
}

protected List<String> getExcludedPaymentMethodsFromConfiguration() {
String excludedPaymentMethodsConfig = configurationService.getConfiguration().getString(EXCLUDED_PAYMENT_METHODS_CONFIG);
if (StringUtils.isEmpty(excludedPaymentMethodsConfig)) {
return new ArrayList<>();
}

String[] excludedPaymentMethods = StringUtils.split(excludedPaymentMethodsConfig, ',');
return Arrays.stream(excludedPaymentMethods).map(String::trim).toList();
}

@Deprecated
public CheckoutConfigDTO getCheckoutConfig() throws ApiException {
final CartData cartData = getCheckoutFacade().getCheckoutCart();
Expand Down

0 comments on commit 1d65005

Please sign in to comment.