Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ECP-9498] Implement onError callback for the Paypal. #2773

Merged
merged 11 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Helper/PaymentsDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
Expand Down
5 changes: 3 additions & 2 deletions view/frontend/web/js/model/adyen-checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -28,7 +28,8 @@ define(
paymentMethodsResponse: paymentMethodsResponse.paymentMethodsResponse,
onAdditionalDetails: handleOnAdditionalDetails,
onCancel: handleOnCancel,
onSubmit: handleOnSubmit
onSubmit: handleOnSubmit,
onError: handleOnError
}
);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ 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',
],
function(
quote,
adyenPaymentMethod,
fullScreenLoader
fullScreenLoader,
adyenPaymentService,
errorProcessor
) {
return adyenPaymentMethod.extend({
placeOrderButtonVisible: false,
khushboo-singhvi marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -32,14 +36,45 @@ define(
},
renderActionComponent: function(resultCode, action, component) {
fullScreenLoader.stopLoader();

this.token = action.sdkData.token;
this.actionComponent = component.handleAction(action);
},
handleOnFailure: function(response, component) {
this.isPlaceOrderAllowed(true);
fullScreenLoader.stopLoader();
component.handleReject(response);
},
handleOnError: function (error, component) {
console.log("onError:",error);
khushboo-singhvi marked this conversation as resolved.
Show resolved Hide resolved

// call endpoint with component.paymentData if available
let request = {};
if (!!component.paymentData) {
request.paymentData = component.paymentData;
}
//Create details array for the payload
let details ={};
khushboo-singhvi marked this conversation as resolved.
Show resolved Hide resolved
if(!!this.token) {
details.orderID= this.token;
khushboo-singhvi marked this conversation as resolved.
Show resolved Hide resolved
}
request.details = details;
request.cancelled = true;
khushboo-singhvi marked this conversation as resolved.
Show resolved Hide resolved

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);
});
}
})
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -374,15 +375,21 @@ define(

try {
const orderId = await placeOrderAction(data, self.currentMessageContainer);
self.afterPlaceOrder();
//self.afterPlaceOrder();
khushboo-singhvi marked this conversation as resolved.
Show resolved Hide resolved
const responseJSON = await adyenPaymentService.getOrderPaymentStatus(orderId);
self.validateActionOrPlaceOrder(responseJSON, orderId, component);
} catch (response) {
self.handleOnFailure(response, component);
}
},


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();
Expand Down
Loading