diff --git a/adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTO.java b/adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTO.java index 852d013b..4b66a78f 100644 --- a/adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTO.java +++ b/adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTO.java @@ -4,8 +4,8 @@ import com.adyen.model.checkout.CreateCheckoutSessionResponse; import com.adyen.model.checkout.PaymentMethod; import com.adyen.model.checkout.StoredPaymentMethod; -import com.adyen.v6.enums.AdyenCardTypeEnum; +import java.math.BigDecimal; import java.util.List; import java.util.Map; @@ -40,6 +40,7 @@ public class CheckoutConfigDTO { private String countryCode; private boolean cardHolderNameRequired; private boolean sepaDirectDebit; + private BigDecimal amountDecimal; public List getAlternativePaymentMethods() { @@ -249,4 +250,12 @@ public List getPaymentMethods() { public void setPaymentMethods(List paymentMethods) { this.paymentMethods = paymentMethods; } + + public BigDecimal getAmountDecimal() { + return amountDecimal; + } + + public void setAmountDecimal(BigDecimal amountDecimal) { + this.amountDecimal = amountDecimal; + } } \ No newline at end of file diff --git a/adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTOBuilder.java b/adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTOBuilder.java index a6fe1710..ea8b9c92 100644 --- a/adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTOBuilder.java +++ b/adyenv6core/src/com/adyen/v6/dto/CheckoutConfigDTOBuilder.java @@ -7,6 +7,7 @@ import com.adyen.model.checkout.StoredPaymentMethod; import com.adyen.v6.enums.AdyenCardTypeEnum; +import java.math.BigDecimal; import java.util.List; import java.util.Map; @@ -149,6 +150,11 @@ public CheckoutConfigDTOBuilder setSepaDirectDebit(boolean sepaDirectDebit) { return this; } + public CheckoutConfigDTOBuilder setAmountDecimal(BigDecimal amountDecimal) { + checkoutConfigDTO.setAmountDecimal(amountDecimal); + return this; + } + public CheckoutConfigDTO build() { return checkoutConfigDTO; } diff --git a/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java b/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java index ca7a94e5..a051ff15 100644 --- a/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java +++ b/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java @@ -780,8 +780,9 @@ public CheckoutConfigDTO getReactCheckoutConfig() throws ApiException { .setShowComboCard(showComboCard()) .setShowPos(showPos()) .setImmediateCapture(isImmediateCapture()) - .setCountryCode(cartData.getDeliveryAddress().getCountry().getIsocode()) + .setCountryCode(cartData != null && cartData.getDeliveryAddress() != null && cartData.getDeliveryAddress().getCountry() != null ? cartData.getDeliveryAddress().getCountry().getIsocode() : "") .setCardHolderNameRequired(getHolderNameRequired()) + .setAmountDecimal(cartData.getTotalPriceWithTax().getValue()) .build(); } @@ -904,6 +905,7 @@ public CheckoutConfigDTO getCheckoutConfig() throws ApiException { .setCountryCode(cartData.getDeliveryAddress().getCountry().getIsocode()) .setCardHolderNameRequired(getHolderNameRequired()) .setSepaDirectDebit(sepaDirectDebit) + .setAmountDecimal(cartData.getTotalPriceWithTax().getValue()) .build(); } @@ -958,11 +960,16 @@ protected PaymentMethodsResponse getPaymentMethods(AdyenCheckoutApiService adyen } protected PaymentMethodsResponse getPaymentMethods(AdyenCheckoutApiService adyenPaymentService, CartData cartData, CustomerModel customerModel, List excludedPaymentMethods) throws IOException, ApiException { - return adyenPaymentService.getPaymentMethodsResponse(cartData.getTotalPriceWithTax().getValue(), - cartData.getTotalPriceWithTax().getCurrencyIso(), - cartData.getDeliveryAddress().getCountry().getIsocode(), - getShopperLocale(), - customerModel.getCustomerID(), excludedPaymentMethods); + if (adyenPaymentService == null || cartData == null || customerModel == null) { + throw new IllegalArgumentException("Required parameters cannot be null"); + } + + BigDecimal totalPrice = cartData.getTotalPriceWithTax() != null ? cartData.getTotalPriceWithTax().getValue() : BigDecimal.ZERO; + String currencyIso = cartData.getTotalPriceWithTax() != null ? cartData.getTotalPriceWithTax().getCurrencyIso() : StringUtils.EMPTY; + String countryIso = cartData.getDeliveryAddress() != null && cartData.getDeliveryAddress().getCountry() != null ? cartData.getDeliveryAddress().getCountry().getIsocode() : StringUtils.EMPTY; + String customerID = customerModel.getCustomerID() != null ? customerModel.getCustomerID() : StringUtils.EMPTY; + + return adyenPaymentService.getPaymentMethodsResponse(totalPrice, currencyIso, countryIso, getShopperLocale(), customerID, excludedPaymentMethods); } @@ -1219,7 +1226,15 @@ public boolean showRememberDetails() { public boolean showSocialSecurityNumber() { Boolean showSocialSecurityNumber = false; CartData cart = getCheckoutFacade().getCheckoutCart(); + if (cart == null) { + return showSocialSecurityNumber; + } + final AddressData deliveryAddress = cart.getDeliveryAddress(); + if (deliveryAddress == null || deliveryAddress.getCountry() == null) { + return showSocialSecurityNumber; + } + String countryCode = deliveryAddress.getCountry().getIsocode(); if (PAYMENT_METHODS_ALLOW_SOCIAL_SECURITY_NUMBER.contains(cart.getAdyenPaymentMethod()) && OPENINVOICE_METHODS_ALLOW_SOCIAL_SECURITY_NUMBER.contains(countryCode)) { showSocialSecurityNumber = true;