From cf017fb80bef3b5192c5fbc94dfa625c65e51872 Mon Sep 17 00:00:00 2001 From: swtmply Date: Wed, 15 Mar 2023 03:45:08 +0800 Subject: [PATCH] fixed the duplicate non-approval call from intellipay --- .../card-payment-modal.component..jsx | 42 +++++++++++-------- .../card-payment-modal.container..jsx | 2 +- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/client/src/components/card-payment-modal/card-payment-modal.component..jsx b/client/src/components/card-payment-modal/card-payment-modal.component..jsx index cd4c6c72c..658019872 100644 --- a/client/src/components/card-payment-modal/card-payment-modal.component..jsx +++ b/client/src/components/card-payment-modal/card-payment-modal.component..jsx @@ -49,8 +49,6 @@ const CardPaymentModalComponent = ({ document.documentElement.appendChild(node); window.intellipay.initialize(); - // console.log("Declined Payments - Intellipay", window.intellipay); - window.intellipay.runOnClose(() => { window.intellipay.initialize(); }); @@ -63,22 +61,20 @@ const CardPaymentModalComponent = ({ }); window.intellipay.runOnNonApproval(async function (response) { - console.log("Declined Payments", response); // Mutate unsuccessful payment - - // await insertPaymentResponse({ - // variables: { - // paymentResponse: { - // amount: response.amount, - // bodyshopid: bodyshop.id, - // jobid: jobid || context.jobid, - // declinereason: response.declinereason, - // ext_paymentid: response.paymentid.toString(), - // successful: false, - // response, - // }, - // }, - // }); + await insertPaymentResponse({ + variables: { + paymentResponse: { + amount: response.amount, + bodyshopid: bodyshop.id, + jobid: jobid || context.jobid, + declinereason: response.declinereason, + ext_paymentid: response.paymentid.toString(), + successful: false, + response, + }, + }, + }); // Insert failed payment to audit trail insertAuditTrail({ @@ -93,6 +89,18 @@ const CardPaymentModalComponent = ({ } form.setFieldValue("payer", t("payments.labels.customer")); + + function handleEvents(...props) { + const operation = props[0].data.operation; + + if (operation === "updateform") { + props[0].stopImmediatePropagation(); + } + } + + window.addEventListener("message", handleEvents, false); + + return () => window.removeEventListener("message", handleEvents, false); }, []); const handleFinish = async (values) => { diff --git a/client/src/components/card-payment-modal/card-payment-modal.container..jsx b/client/src/components/card-payment-modal/card-payment-modal.container..jsx index ffeefcef0..a06692dbb 100644 --- a/client/src/components/card-payment-modal/card-payment-modal.container..jsx +++ b/client/src/components/card-payment-modal/card-payment-modal.container..jsx @@ -41,7 +41,7 @@ function CardPaymentModalContainer({ Go Back , ]} - width="50%" + width="60%" destroyOnClose >