diff --git a/.github/Makefile b/.github/Makefile index ba3317602..4aabb10e8 100644 --- a/.github/Makefile +++ b/.github/Makefile @@ -44,7 +44,7 @@ configure: n98-magerun2.phar bin/magento config:set payment/adyen_abstract/payment_pre_authorized 'pending_payment' bin/magento config:set payment/adyen_abstract/capture_mode 'manual' bin/magento config:set payment/adyen_abstract/paypal_capture_mode 0 - bin/magento config:set payment/adyen_abstract/recurring_configuration '{"adyen_cc":{"name":"Credit Card","enabled":"1","recurringProcessingModel":"CardOnFile"}}' + bin/magento config:set payment/adyen_abstract/recurring_configuration '{"adyen_cc":{"name":"Cards","enabled":"1","recurringProcessingModel":"CardOnFile"},"adyen_sepadirectdebit":{"name":"SEPA Direct Debit","enabled":"1","recurringProcessingModel":"CardOnFile"}}' bin/magento config:set payment/adyen_cc_vault/require_cvc 1 bin/magento config:set payment/adyen_abstract/client_key_test "${ADYEN_CLIENT_KEY}" bin/magento config:set payment/adyen_abstract/notification_username 'admin' diff --git a/Helper/PaymentsDetails.php b/Helper/PaymentsDetails.php index db54ba2ef..23837c2fa 100644 --- a/Helper/PaymentsDetails.php +++ b/Helper/PaymentsDetails.php @@ -111,7 +111,7 @@ private function cleanUpPaymentDetailsPayload(array $payload): array ); foreach (self::REQUEST_HELPER_PARAMETERS as $helperParam) { - if (array_key_exists($helperParam, $payload['details'])) { + if (isset($payload['details']) && array_key_exists($helperParam, $payload['details'])) { unset($payload['details'][$helperParam]); } } diff --git a/view/frontend/web/js/model/adyen-checkout.js b/view/frontend/web/js/model/adyen-checkout.js index c64675483..8b5a138c4 100644 --- a/view/frontend/web/js/model/adyen-checkout.js +++ b/view/frontend/web/js/model/adyen-checkout.js @@ -19,7 +19,7 @@ define( ) { 'use strict'; return { - buildCheckoutComponent: function (paymentMethodsResponse, handleOnAdditionalDetails, handleOnCancel = undefined, handleOnSubmit = undefined) { + buildCheckoutComponent: function (paymentMethodsResponse, handleOnAdditionalDetails, handleOnCancel = undefined, handleOnSubmit = undefined, handleOnError = undefined) { if (!!paymentMethodsResponse.paymentMethodsResponse) { return AdyenCheckout({ locale: adyenConfiguration.getLocale(), @@ -28,7 +28,8 @@ define( paymentMethodsResponse: paymentMethodsResponse.paymentMethodsResponse, onAdditionalDetails: handleOnAdditionalDetails, onCancel: handleOnCancel, - onSubmit: handleOnSubmit + onSubmit: handleOnSubmit, + onError: handleOnError } ); } else { diff --git a/view/frontend/web/js/view/payment/method-renderer/adyen-paypal-method.js b/view/frontend/web/js/view/payment/method-renderer/adyen-paypal-method.js index 7cda6b53f..bd7eb634b 100644 --- a/view/frontend/web/js/view/payment/method-renderer/adyen-paypal-method.js +++ b/view/frontend/web/js/view/payment/method-renderer/adyen-paypal-method.js @@ -12,14 +12,21 @@ define( 'Magento_Checkout/js/model/quote', 'Adyen_Payment/js/view/payment/method-renderer/adyen-pm-method', 'Magento_Checkout/js/model/full-screen-loader', + 'Adyen_Payment/js/model/adyen-payment-service', + 'Magento_Checkout/js/model/error-processor', + 'Adyen_Payment/js/model/adyen-configuration' ], function( quote, adyenPaymentMethod, - fullScreenLoader + fullScreenLoader, + adyenPaymentService, + errorProcessor, + adyenConfiguration ) { return adyenPaymentMethod.extend({ placeOrderButtonVisible: false, + token: null, initialize: function () { this._super(); }, @@ -32,7 +39,7 @@ define( }, renderActionComponent: function(resultCode, action, component) { fullScreenLoader.stopLoader(); - + this.token = action.sdkData.token; this.actionComponent = component.handleAction(action); }, handleOnFailure: function(response, component) { @@ -40,6 +47,39 @@ define( fullScreenLoader.stopLoader(); component.handleReject(response); }, + handleOnError: function (error, component) { + if ('test' === adyenConfiguration.getCheckoutEnvironment()) { + console.log("onError:",error); + } + + // call endpoint with component.paymentData if available + let request = {}; + if (!!component.paymentData) { + request.paymentData = component.paymentData; + } + + //Create details array for the payload + let details = {}; + if(!!this.token) { + details.orderID = this.token; + } + request.details = details; + + adyenPaymentService.paymentDetails(request, this.orderId).done(function() { + $.mage.redirect( + window.checkoutConfig.payment.adyen.successPage + ); + }).fail(function(response) { + fullScreenLoader.stopLoader(); + if (this.popupModal) { + this.closeModal(this.popupModal); + } + errorProcessor.process(response, + this.currentMessageContainer); + this.isPlaceOrderAllowed(true); + this.showErrorMessage(response); + }); + } }) } ); diff --git a/view/frontend/web/js/view/payment/method-renderer/adyen-pm-method.js b/view/frontend/web/js/view/payment/method-renderer/adyen-pm-method.js index e380a6413..a5609a8ad 100755 --- a/view/frontend/web/js/view/payment/method-renderer/adyen-pm-method.js +++ b/view/frontend/web/js/view/payment/method-renderer/adyen-pm-method.js @@ -87,7 +87,8 @@ define( paymentMethodsResponse, this.handleOnAdditionalDetails.bind(this), this.handleOnCancel.bind(this), - this.handleOnSubmit.bind(this) + this.handleOnSubmit.bind(this), + this.handleOnError.bind(this) ); if (!!this.checkoutComponent) { @@ -374,7 +375,6 @@ define( try { const orderId = await placeOrderAction(data, self.currentMessageContainer); - self.afterPlaceOrder(); const responseJSON = await adyenPaymentService.getOrderPaymentStatus(orderId); self.validateActionOrPlaceOrder(responseJSON, orderId, component); } catch (response) { @@ -382,7 +382,13 @@ define( } }, - + handleOnError: function (error, component) { + /* + * Passing false as the response to hide the actual error message from the shopper for security. + * This will show a generic error message instead of the actual error message. + */ + this.handleOnFailure(error, component); + }, handleOnFailure: function(response, component) { this.isPlaceOrderAllowed(true); fullScreenLoader.stopLoader();