From 9ca49fdd2d5da3a5c5e105ab56ada9c48ca7db0d Mon Sep 17 00:00:00 2001 From: PJaneta Date: Fri, 3 Jan 2025 14:44:34 +0100 Subject: [PATCH] AD-388 Problem with Google Pay express: NullPointerException --- .../impl/DefaultAdyenCheckoutFacade.java | 45 ++++--------------- 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java b/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java index e7eb9df6..32fee462 100644 --- a/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java +++ b/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java @@ -22,17 +22,7 @@ import com.adyen.commerce.data.PaymentMethodsCartData; -import com.adyen.model.checkout.Amount; -import com.adyen.model.checkout.CreateCheckoutSessionResponse; -import com.adyen.model.checkout.PaymentCompletionDetails; -import com.adyen.model.checkout.PaymentDetailsRequest; -import com.adyen.model.checkout.PaymentDetailsResponse; -import com.adyen.model.checkout.PaymentMethod; -import com.adyen.model.checkout.PaymentMethodsResponse; -import com.adyen.model.checkout.PaymentRequest; -import com.adyen.model.checkout.PaymentResponse; -import com.adyen.model.checkout.PaymentResponseAction; -import com.adyen.model.checkout.StoredPaymentMethod; +import com.adyen.model.checkout.*; import com.adyen.model.nexo.ErrorConditionType; import com.adyen.model.nexo.ResultType; import com.adyen.model.recurring.Recurring; @@ -111,43 +101,20 @@ import org.springframework.beans.factory.annotation.Required; import org.springframework.transaction.support.TransactionOperations; import org.springframework.ui.Model; +import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; import org.springframework.validation.Errors; import javax.servlet.http.HttpServletRequest; import java.io.IOException; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Arrays; -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; import static com.adyen.constants.ApiConstants.ThreeDS2Property.THREEDS2_CHALLENGE_TOKEN; import static com.adyen.constants.ApiConstants.ThreeDS2Property.THREEDS2_FINGERPRINT_TOKEN; -import static com.adyen.v6.constants.Adyenv6coreConstants.ISSUER_PAYMENT_METHODS; -import static com.adyen.v6.constants.Adyenv6coreConstants.OPENINVOICE_METHODS_ALLOW_SOCIAL_SECURITY_NUMBER; -import static com.adyen.v6.constants.Adyenv6coreConstants.OPENINVOICE_METHODS_API; -import static com.adyen.v6.constants.Adyenv6coreConstants.PAYBRIGHT; -import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD; -import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHODS_ALLOW_SOCIAL_SECURITY_NUMBER; -import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_AMAZONPAY; -import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_APPLEPAY; -import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_BOLETO; -import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_KLARNA; -import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_ONLINEBANKING_IN; -import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_ONLINEBANKING_PL; -import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_SCHEME; -import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_SEPA_DIRECTDEBIT; -import static com.adyen.v6.constants.Adyenv6coreConstants.SHOPPER_LOCALE; +import static com.adyen.v6.constants.Adyenv6coreConstants.*; import static de.hybris.platform.order.impl.DefaultCartService.SESSION_CART_PARAMETER_NAME; /** @@ -715,6 +682,8 @@ public CheckoutConfigDTO getReactCheckoutConfig() throws ApiException { PaymentMethodsResponse response = new PaymentMethodsResponse(); CartModel cartModel = cartService.getSessionCart(); + Assert.notNull(cartModel.getDeliveryAddress(), "Delivery address is required"); + //to remove unwanted payment methods insert them here List excludedPaymentMethods = getExcludedPaymentMethodsFromConfiguration(); LOGGER.info(excludedPaymentMethods.toString()); @@ -848,6 +817,8 @@ public CheckoutConfigDTO getCheckoutConfig() throws ApiException { PaymentMethodsResponse response = new PaymentMethodsResponse(); CartModel cartModel = cartService.getSessionCart(); + Assert.notNull(cartModel.getDeliveryAddress(), "Delivery address is required"); + try { if (showPos()) { connectedTerminalList = adyenCheckoutApiService.getConnectedTerminals().getUniqueTerminalIds();