From 491fc4474e8db19a871041042585615551678aa0 Mon Sep 17 00:00:00 2001 From: kpieloch <113994423+kpieloch@users.noreply.github.com> Date: Mon, 6 May 2024 11:04:17 +0200 Subject: [PATCH] [AD-234] Fix for payment methods that don't work --- .../responsive/common/js/adyen.checkout.js | 9 ++-- .../adyen/v6/factory/AdyenRequestFactory.java | 41 +------------------ 2 files changed, 5 insertions(+), 45 deletions(-) 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 2d116dc3..738a9335 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 @@ -1061,7 +1061,7 @@ var AdyenCheckoutHybris = (function () { self.submitDetails(state.data, self.handleResult); }, onError: function (error, component) { - console.log('Something went wrong trying to make the Gift Card payment: ' + error); + console.log('Something went wrong trying to make a payment: ' + error); self.handleResult(ErrorMessages.PaymentError, true); } }); @@ -1070,7 +1070,7 @@ var AdyenCheckoutHybris = (function () { adyenComponent.mount(paymentNode); self.configureButton(adyenComponent, false, label); } catch (e) { - console.log('Something went wrong trying to mount the Gift Card component: ' + e); + console.log('Something went wrong trying to mount component: ' + e); } }, @@ -1099,9 +1099,8 @@ var AdyenCheckoutHybris = (function () { contentType: "application/json; charset=utf-8", success: function (response) { try { - if (response.resultCode && response.resultCode === 'Pending' && response.action) { - component.handleAction(response.action); - } else if (response.resultCode && (response.resultCode === 'RedirectShopper')) { + if (response.action && (response.resultCode && response.resultCode === 'Pending' || + response.resultCode && (response.resultCode === 'RedirectShopper'))) { component.handleAction(response.action); } else if (response.resultCode && (response.resultCode === 'Authorised')) { handleResult(response, false); diff --git a/adyenv6core/src/com/adyen/v6/factory/AdyenRequestFactory.java b/adyenv6core/src/com/adyen/v6/factory/AdyenRequestFactory.java index 406d30a1..c7a4f74a 100644 --- a/adyenv6core/src/com/adyen/v6/factory/AdyenRequestFactory.java +++ b/adyenv6core/src/com/adyen/v6/factory/AdyenRequestFactory.java @@ -29,15 +29,11 @@ import com.adyen.model.checkout.CheckoutPaymentMethod; import com.adyen.model.checkout.CommonField; import com.adyen.model.checkout.DeliveryAddress; -import com.adyen.model.checkout.DotpayDetails; import com.adyen.model.checkout.ExternalPlatform; import com.adyen.model.checkout.Installments; -import com.adyen.model.checkout.KlarnaDetails; import com.adyen.model.checkout.LineItem; import com.adyen.model.checkout.Name; -import com.adyen.model.checkout.PaymentDetails; import com.adyen.model.checkout.PaymentRequest; -import com.adyen.model.checkout.StoredPaymentMethodDetails; import com.adyen.model.nexo.AmountsReq; import com.adyen.model.nexo.DocumentQualifierType; import com.adyen.model.nexo.MessageCategoryType; @@ -122,6 +118,7 @@ public PaymentRequest createPaymentsRequest(final String merchantAccount, final CustomerModel customerModel, final RecurringContractMode recurringContractMode, final Boolean guestUserTokenizationEnabled) { + final String adyenPaymentMethod = cartData.getAdyenPaymentMethod(); final Boolean is3DS2allowed = is3DS2Allowed(); final PaymentRequest paymentsRequest = new PaymentRequest(); @@ -306,7 +303,6 @@ protected void updatePaymentRequestForCC(final PaymentRequest paymentsRequest, f } protected void updatePaymentRequestForDC(final PaymentRequest paymentsRequest, final CartData cartData, final RecurringContractMode recurringContractMode) { - final Recurring recurringContract = getRecurringContractType(recurringContractMode); Recurring.ContractEnum contract = null; if (recurringContract != null) { @@ -348,41 +344,6 @@ protected void updatePaymentRequestForAlternateMethod(final PaymentRequest payme || adyenPaymentMethod.contains(RATEPAY)) { setOpenInvoiceData(paymentsRequest, cartData); } - if (paymentsRequest.getPaymentMethod() == null) { - try { - PaymentDetails paymentDetails = new PaymentDetails(); - paymentDetails.setType(PaymentDetails.TypeEnum.fromValue(adyenPaymentMethod)); - CheckoutPaymentMethod checkoutPaymentMethod = new CheckoutPaymentMethod(paymentDetails); - paymentsRequest.setPaymentMethod(checkoutPaymentMethod); - return; - } catch (IllegalArgumentException e) { - } - try { - StoredPaymentMethodDetails paymentDetails = new StoredPaymentMethodDetails(); - paymentDetails.setType(StoredPaymentMethodDetails.TypeEnum.fromValue(adyenPaymentMethod)); - CheckoutPaymentMethod checkoutPaymentMethod = new CheckoutPaymentMethod(paymentDetails); - paymentsRequest.setPaymentMethod(checkoutPaymentMethod); - return; - } catch (IllegalArgumentException e) { - } - try { - KlarnaDetails paymentDetails = new KlarnaDetails(); - paymentDetails.setType(KlarnaDetails.TypeEnum.fromValue(adyenPaymentMethod)); - CheckoutPaymentMethod checkoutPaymentMethod = new CheckoutPaymentMethod(paymentDetails); - paymentsRequest.setPaymentMethod(checkoutPaymentMethod); - return; - } catch (IllegalArgumentException e) { - } - try { - DotpayDetails paymentDetails = new DotpayDetails(); - paymentDetails.setType(DotpayDetails.TypeEnum.fromValue(adyenPaymentMethod)); - CheckoutPaymentMethod checkoutPaymentMethod = new CheckoutPaymentMethod(paymentDetails); - paymentsRequest.setPaymentMethod(checkoutPaymentMethod); - return; - } catch (IllegalArgumentException e) { - } - LOG.error("Payment method not recognized: " + adyenPaymentMethod); - } } protected String getCountryCode(final CartData cartData) {