removed console log and added the mutation for failed payment attempts
This commit is contained in:
@@ -26,23 +26,30 @@ const CardPaymentModalComponent = ({ bodyshop, context }) => {
|
|||||||
document.documentElement.appendChild(node);
|
document.documentElement.appendChild(node);
|
||||||
window.intellipay.initialize();
|
window.intellipay.initialize();
|
||||||
|
|
||||||
console.log("Modal: Intellipay Initialized");
|
|
||||||
|
|
||||||
window.intellipay.runOnClose(() => {
|
window.intellipay.runOnClose(() => {
|
||||||
// Apparently it automatically removes itself in the document when closed
|
|
||||||
// so we just need to reintialize it
|
|
||||||
window.intellipay.initialize();
|
window.intellipay.initialize();
|
||||||
});
|
});
|
||||||
|
|
||||||
window.intellipay.runOnApproval(async function (response) {
|
window.intellipay.runOnApproval(async function (response) {
|
||||||
console.log("Modal - Payment Response: ", response);
|
|
||||||
// TODO store the response
|
|
||||||
form.setFieldValue("paymentResponse", response);
|
form.setFieldValue("paymentResponse", response);
|
||||||
form.submit();
|
form.submit();
|
||||||
});
|
});
|
||||||
|
|
||||||
window.intellipay.runOnNonApproval(function (response) {
|
window.intellipay.runOnNonApproval(async function (response) {
|
||||||
console.log("Modal: Non Payment: ", response);
|
// Mutate unsuccessful payment
|
||||||
|
await insertPaymentResponse({
|
||||||
|
variables: {
|
||||||
|
paymentResponse: {
|
||||||
|
amount: response.amount,
|
||||||
|
bodyshopid: bodyshop.id,
|
||||||
|
jobid: context.jobid,
|
||||||
|
declinereason: response.declinereason,
|
||||||
|
ext_paymentid: response.paymentid.toString(),
|
||||||
|
successful: false,
|
||||||
|
response,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -54,8 +61,6 @@ const CardPaymentModalComponent = ({ bodyshop, context }) => {
|
|||||||
const disabled = false;
|
const disabled = false;
|
||||||
|
|
||||||
const handleFinish = async (values) => {
|
const handleFinish = async (values) => {
|
||||||
console.log("Modal: Handle Finish Values", values);
|
|
||||||
|
|
||||||
const paymentResult = await insertPayment({
|
const paymentResult = await insertPayment({
|
||||||
variables: {
|
variables: {
|
||||||
paymentInput: {
|
paymentInput: {
|
||||||
@@ -69,7 +74,7 @@ const CardPaymentModalComponent = ({ bodyshop, context }) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const paymentResponseResult = await insertPaymentResponse({
|
await insertPaymentResponse({
|
||||||
variables: {
|
variables: {
|
||||||
paymentResponse: {
|
paymentResponse: {
|
||||||
amount: values.amount,
|
amount: values.amount,
|
||||||
@@ -83,12 +88,6 @@ const CardPaymentModalComponent = ({ bodyshop, context }) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("Modal - Insert Payment Result: ", paymentResult);
|
|
||||||
console.log(
|
|
||||||
"Modal - Insert Respose Payment Result: ",
|
|
||||||
paymentResponseResult
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -121,6 +120,7 @@ const CardPaymentModalComponent = ({ bodyshop, context }) => {
|
|||||||
value={amount}
|
value={amount}
|
||||||
hidden
|
hidden
|
||||||
/>
|
/>
|
||||||
|
{/* Lightbox payment response when it is completed */}
|
||||||
<Form.Item name="paymentResponse" hidden>
|
<Form.Item name="paymentResponse" hidden>
|
||||||
<Input type="hidden" value={amount} />
|
<Input type="hidden" value={amount} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|||||||
Reference in New Issue
Block a user