From f13fc1d987a04c8d51ab831515966effbdcf314c Mon Sep 17 00:00:00 2001 From: Alex P Date: Thu, 19 Oct 2023 16:56:07 +0300 Subject: [PATCH] Redirect to continuation on block server error --- .../ppcp-blocks/resources/js/checkout-block.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/ppcp-blocks/resources/js/checkout-block.js b/modules/ppcp-blocks/resources/js/checkout-block.js index b1073dfb2..85bcd278f 100644 --- a/modules/ppcp-blocks/resources/js/checkout-block.js +++ b/modules/ppcp-blocks/resources/js/checkout-block.js @@ -253,21 +253,24 @@ const PayPalComponent = ({ }, [onPaymentSetup, paypalOrder, activePaymentMethod]); useEffect(() => { + if (activePaymentMethod !== config.id) { + return; + } const unsubscribe = onCheckoutFail(({ processingResponse }) => { + console.error(processingResponse) if (onClose) { onClose(); } - if (processingResponse?.paymentDetails?.errorMessage) { - return { - type: emitResponse.responseTypes.ERROR, - message: processingResponse.paymentDetails.errorMessage, - messageContext: config.scriptData.continuation ? emitResponse.noticeContexts.PAYMENTS : emitResponse.noticeContexts.EXPRESS_PAYMENTS, - }; + if (config.scriptData.continuation) { + return true; + } + if (!config.finalReviewEnabled) { + location.href = getCheckoutRedirectUrl(); } return true; }); return unsubscribe; - }, [onCheckoutFail, onClose]); + }, [onCheckoutFail, onClose, activePaymentMethod]); if (config.scriptData.continuation) { return (