fixed the duplicate non-approval call from intellipay

This commit is contained in:
swtmply
2023-03-15 03:45:08 +08:00
parent 56c366e9e8
commit cf017fb80b
2 changed files with 26 additions and 18 deletions

View File

@@ -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) => {

View File

@@ -41,7 +41,7 @@ function CardPaymentModalContainer({
Go Back
</Button>,
]}
width="50%"
width="60%"
destroyOnClose
>
<CardPaymentModalComponent bodyshop={bodyshop} context={context} />