Skip to content

Commit

Permalink
[AD-234] Fix for payment methods that don't work
Browse files Browse the repository at this point in the history
  • Loading branch information
kpieloch committed May 9, 2024
1 parent 491fc44 commit d719be9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -116,6 +118,9 @@ public ResponseEntity<PaymentResponse> 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) {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@
fnCallbackArray['initiateBlik'] = callbackConfig
</c:when>
<c:when test="${selectedPaymentMethod eq 'adyen_cc'}">
AdyenCheckoutHybris.configureButton($("#placeOrderForm-hidden-xs"), true, "hidden-xs");
AdyenCheckoutHybris.configureButton($("#placeOrderForm-visible-xs"), true, "visible-xs");
</c:when>
<%-- API only payments methods --%>
<c:otherwise>
fnCallbackArray['initiatePayment'] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -482,7 +493,6 @@ public PaymentResponse componentPayment(final HttpServletRequest request, final
createAuthorizedOrder(paymentResponse);
return paymentResponse;
}

throw new AdyenNonAuthorizedPaymentException(paymentResponse);
}

Expand Down
3 changes: 0 additions & 3 deletions adyenv6core/src/com/adyen/v6/factory/AdyenRequestFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit d719be9

Please sign in to comment.