From d719be9527fc06be2d781fc4da592969012070a1 Mon Sep 17 00:00:00 2001 From: kpieloch <113994423+kpieloch@users.noreply.github.com> Date: Thu, 9 May 2024 10:03:01 +0200 Subject: [PATCH] [AD-234] Fix for payment methods that don't work --- .../pages/AdyenComponentController.java | 8 +++++++- .../pages/checkout/multi/checkoutSummaryPage.jsp | 5 +++++ .../_ui/responsive/common/js/adyen.checkout.js | 6 ++++-- .../facades/impl/DefaultAdyenCheckoutFacade.java | 16 +++++++++++++--- .../adyen/v6/factory/AdyenRequestFactory.java | 3 --- 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/adyenv6b2ccheckoutaddon/acceleratoraddon/web/src/com/adyen/v6/controllers/pages/AdyenComponentController.java b/adyenv6b2ccheckoutaddon/acceleratoraddon/web/src/com/adyen/v6/controllers/pages/AdyenComponentController.java index 67836b4b..d5946f64 100644 --- a/adyenv6b2ccheckoutaddon/acceleratoraddon/web/src/com/adyen/v6/controllers/pages/AdyenComponentController.java +++ b/adyenv6b2ccheckoutaddon/acceleratoraddon/web/src/com/adyen/v6/controllers/pages/AdyenComponentController.java @@ -58,12 +58,14 @@ import javax.servlet.http.HttpServletRequest; import java.util.Arrays; import java.util.List; +import java.util.Objects; import static com.adyen.v6.constants.AdyenControllerConstants.COMPONENT_PREFIX; import static com.adyen.v6.constants.AdyenControllerConstants.SUMMARY_CHECKOUT_PREFIX; import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_AMAZONPAY; import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_BCMC_MOBILE; import static com.adyen.v6.constants.Adyenv6coreConstants.PAYMENT_METHOD_PIX; +import static com.adyen.v6.controllers.pages.AdyenSummaryCheckoutStepController.CHECKOUT_RESULT_URL; @RestController @RequestMapping(COMPONENT_PREFIX) @@ -116,6 +118,9 @@ public ResponseEntity componentPayment(@RequestHeader String ho LOGGER.error("ApiException: " + e); throw new AdyenComponentException("checkout.error.authorization.payment.refused"); } catch (AdyenNonAuthorizedPaymentException e) { + if (Objects.nonNull(e.getPaymentsResponse()) && Objects.nonNull(e.getPaymentsResponse().getAction())) { + return ResponseEntity.ok().body(e.getPaymentsResponse()); + } LOGGER.warn("AdyenNonAuthorizedPaymentException occurred. Payment " + e.getPaymentResult().getPspReference() + "is refused."); throw new AdyenComponentException("checkout.error.authorization.payment.refused"); } catch (Exception e) { @@ -183,7 +188,8 @@ private String getReturnUrl(String paymentMethod) { //Google Pay will only use returnUrl if redirected to 3DS authentication url = SUMMARY_CHECKOUT_PREFIX + "/authorise-3d-adyen-response"; } else { - url = COMPONENT_PREFIX + "/submit-details"; + url = SUMMARY_CHECKOUT_PREFIX + CHECKOUT_RESULT_URL; + ; } BaseSiteModel currentBaseSite = baseSiteService.getCurrentBaseSite(); return siteBaseUrlResolutionService.getWebsiteUrlForSite(currentBaseSite, true, url); diff --git a/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/WEB-INF/views/responsive/pages/checkout/multi/checkoutSummaryPage.jsp b/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/WEB-INF/views/responsive/pages/checkout/multi/checkoutSummaryPage.jsp index eb54c5de..b5704de9 100644 --- a/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/WEB-INF/views/responsive/pages/checkout/multi/checkoutSummaryPage.jsp +++ b/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/WEB-INF/views/responsive/pages/checkout/multi/checkoutSummaryPage.jsp @@ -109,6 +109,11 @@ fnCallbackArray['initiateBlik'] = callbackConfig + + AdyenCheckoutHybris.configureButton($("#placeOrderForm-hidden-xs"), true, "hidden-xs"); + AdyenCheckoutHybris.configureButton($("#placeOrderForm-visible-xs"), true, "visible-xs"); + + <%-- API only payments methods --%> fnCallbackArray['initiatePayment'] = { diff --git a/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen.checkout.js b/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen.checkout.js index 738a9335..496f79f4 100644 --- a/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen.checkout.js +++ b/adyenv6b2ccheckoutaddon/acceleratoraddon/web/webroot/_ui/responsive/common/js/adyen.checkout.js @@ -1099,8 +1099,10 @@ var AdyenCheckoutHybris = (function () { contentType: "application/json; charset=utf-8", success: function (response) { try { - if (response.action && (response.resultCode && response.resultCode === 'Pending' || - response.resultCode && (response.resultCode === 'RedirectShopper'))) { + if (response.action && (response.resultCode && (response.resultCode === 'Pending' || + response.resultCode === 'RedirectShopper' || response.resultCode === 'IdentifyShopper' || + response.resultCode === 'ChallengeShopper' || response.resultCode === 'PresentToShopper' || + response.resultCode === 'Await') || (response.action && response.action.type))) { component.handleAction(response.action); } else if (response.resultCode && (response.resultCode === 'Authorised')) { handleResult(response, false); diff --git a/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java b/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java index f602731a..110a596f 100644 --- a/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java +++ b/adyenv6core/src/com/adyen/v6/facades/impl/DefaultAdyenCheckoutFacade.java @@ -113,7 +113,16 @@ import javax.servlet.http.HttpServletRequest; import java.io.IOException; import java.math.BigDecimal; -import java.util.*; +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.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -472,7 +481,9 @@ public PaymentResponse componentPayment(final HttpServletRequest request, final requestInfo.setShopperLocale(getShopperLocale()); PaymentResponse paymentResponse = getAdyenPaymentService().componentPayment(cartData, paymentRequest, requestInfo, getCheckoutCustomerStrategy().getCurrentUserForCheckout()); - if (PaymentResponse.ResultCodeEnum.PENDING == paymentResponse.getResultCode() || PaymentResponse.ResultCodeEnum.REDIRECTSHOPPER == paymentResponse.getResultCode()) { + if (PaymentResponse.ResultCodeEnum.PENDING == paymentResponse.getResultCode() || + PaymentResponse.ResultCodeEnum.REDIRECTSHOPPER == paymentResponse.getResultCode() || + PaymentResponse.ResultCodeEnum.PRESENTTOSHOPPER == paymentResponse.getResultCode()) { LOGGER.info("Placing pending order"); placePendingOrder(paymentResponse.getResultCode().getValue()); return paymentResponse; @@ -482,7 +493,6 @@ public PaymentResponse componentPayment(final HttpServletRequest request, final createAuthorizedOrder(paymentResponse); return paymentResponse; } - throw new AdyenNonAuthorizedPaymentException(paymentResponse); } diff --git a/adyenv6core/src/com/adyen/v6/factory/AdyenRequestFactory.java b/adyenv6core/src/com/adyen/v6/factory/AdyenRequestFactory.java index c7a4f74a..f755fd53 100644 --- a/adyenv6core/src/com/adyen/v6/factory/AdyenRequestFactory.java +++ b/adyenv6core/src/com/adyen/v6/factory/AdyenRequestFactory.java @@ -123,9 +123,6 @@ public PaymentRequest createPaymentsRequest(final String merchantAccount, final Boolean is3DS2allowed = is3DS2Allowed(); final PaymentRequest paymentsRequest = new PaymentRequest(); - if (adyenPaymentMethod == null) { - throw new IllegalArgumentException("Payment method is null"); - } //Update payment request for generic information for all payment method types setCommonInfoOnPaymentRequest(merchantAccount, cartData, requestInfo, customerModel, paymentsRequest); paymentsRequest.setApplicationInfo(createApplicationInfo());