code cleanup and translations
This commit is contained in:
@@ -236,7 +236,7 @@ const CardPaymentModalComponent = ({
|
|||||||
className="ipayfield"
|
className="ipayfield"
|
||||||
disabled={!amount || !payer || !jobid}
|
disabled={!amount || !payer || !jobid}
|
||||||
>
|
>
|
||||||
Proceed to Payment
|
{t("job_payments.buttons.proceedtopayment")}
|
||||||
</Button>
|
</Button>
|
||||||
{context?.balance && (
|
{context?.balance && (
|
||||||
<DataLabel
|
<DataLabel
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Button, Modal } from "antd";
|
import { Button, Modal } from "antd";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { toggleModalVisible } from "../../redux/modals/modals.actions";
|
import { toggleModalVisible } from "../../redux/modals/modals.actions";
|
||||||
@@ -22,6 +23,7 @@ function CardPaymentModalContainer({
|
|||||||
bodyshop,
|
bodyshop,
|
||||||
}) {
|
}) {
|
||||||
const { context, visible } = cardPaymentModal;
|
const { context, visible } = cardPaymentModal;
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
toggleModalVisible();
|
toggleModalVisible();
|
||||||
@@ -38,7 +40,7 @@ function CardPaymentModalContainer({
|
|||||||
onCancel={handleCancel}
|
onCancel={handleCancel}
|
||||||
footer={[
|
footer={[
|
||||||
<Button key="back" onClick={handleCancel}>
|
<Button key="back" onClick={handleCancel}>
|
||||||
Go Back
|
{t("job_payments.buttons.goback")}
|
||||||
</Button>,
|
</Button>,
|
||||||
]}
|
]}
|
||||||
width="60%"
|
width="60%"
|
||||||
|
|||||||
@@ -5,17 +5,26 @@ import {
|
|||||||
INSERT_PAYMENT_RESPONSE,
|
INSERT_PAYMENT_RESPONSE,
|
||||||
QUERY_PAYMENT_RESPONSE_BY_PAYMENT_ID,
|
QUERY_PAYMENT_RESPONSE_BY_PAYMENT_ID,
|
||||||
} from "../../graphql/payment_response.queries";
|
} from "../../graphql/payment_response.queries";
|
||||||
import { Button, Descriptions, InputNumber, Modal } from "antd";
|
import { Button, Descriptions, InputNumber, Modal, notification } from "antd";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { INSERT_NEW_PAYMENT } from "../../graphql/payments.queries";
|
import { INSERT_NEW_PAYMENT } from "../../graphql/payments.queries";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
const { confirm } = Modal;
|
const { confirm } = Modal;
|
||||||
|
|
||||||
|
const openNotificationWithIcon = (type, t) => {
|
||||||
|
notification[type]({
|
||||||
|
message: t("job_payments.notifications.error.title"),
|
||||||
|
description: t("job_payments.notifications.error.description"),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const PaymentExpandedRowComponent = ({ record }) => {
|
const PaymentExpandedRowComponent = ({ record }) => {
|
||||||
const [refundAmount, setRefundAmount] = useState(0);
|
const [refundAmount, setRefundAmount] = useState(0);
|
||||||
const [insertPayment] = useMutation(INSERT_NEW_PAYMENT);
|
const [insertPayment] = useMutation(INSERT_NEW_PAYMENT);
|
||||||
const [insertPaymentResponse] = useMutation(INSERT_PAYMENT_RESPONSE);
|
const [insertPaymentResponse] = useMutation(INSERT_PAYMENT_RESPONSE);
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const { loading, error, data } = useQuery(
|
const { loading, error, data } = useQuery(
|
||||||
QUERY_PAYMENT_RESPONSE_BY_PAYMENT_ID,
|
QUERY_PAYMENT_RESPONSE_BY_PAYMENT_ID,
|
||||||
@@ -28,11 +37,14 @@ const PaymentExpandedRowComponent = ({ record }) => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const { data: refundable_amount } = useQuery(GET_REFUNDABLE_AMOUNT_BY_JOBID, {
|
const { data: refundable_amount, refetch } = useQuery(
|
||||||
variables: {
|
GET_REFUNDABLE_AMOUNT_BY_JOBID,
|
||||||
jobid: record.jobid,
|
{
|
||||||
},
|
variables: {
|
||||||
});
|
jobid: record.jobid,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const insertPayments = async (payment_response, refund_response) => {
|
const insertPayments = async (payment_response, refund_response) => {
|
||||||
await insertPayment({
|
await insertPayment({
|
||||||
@@ -88,7 +100,15 @@ const PaymentExpandedRowComponent = ({ record }) => {
|
|||||||
paymentid: payment_response.ext_paymentid,
|
paymentid: payment_response.ext_paymentid,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (refundResponse.data.status < 0) {
|
||||||
|
openNotificationWithIcon("error", t);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
insertPayments(payment_response, refundResponse);
|
insertPayments(payment_response, refundResponse);
|
||||||
|
|
||||||
|
// refetch refundable amount
|
||||||
|
refetch();
|
||||||
},
|
},
|
||||||
onCancel() {},
|
onCancel() {},
|
||||||
});
|
});
|
||||||
@@ -100,34 +120,38 @@ const PaymentExpandedRowComponent = ({ record }) => {
|
|||||||
|
|
||||||
const payment_response = data.payment_response[0];
|
const payment_response = data.payment_response[0];
|
||||||
const max_refundable_amount =
|
const max_refundable_amount =
|
||||||
refundable_amount.payment_response_aggregate.aggregate.sum.amount;
|
refundable_amount?.payment_response_aggregate.aggregate.sum.amount;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Descriptions
|
<Descriptions
|
||||||
title="Payment Details"
|
title={t("job_payments.titles.descriptions")}
|
||||||
contentStyle={{ fontWeight: "600" }}
|
contentStyle={{ fontWeight: "600" }}
|
||||||
column={4}
|
column={4}
|
||||||
>
|
>
|
||||||
<Descriptions.Item label="Payer">{record.payer}</Descriptions.Item>
|
<Descriptions.Item label={t("job_payments.titles.payer")}>
|
||||||
<Descriptions.Item label="Payer Name">
|
{record.payer}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label={t("job_payments.titles.payername")}>
|
||||||
{payment_response?.response?.nameOnCard ?? ""}
|
{payment_response?.response?.nameOnCard ?? ""}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="Amount">{record.amount}</Descriptions.Item>
|
<Descriptions.Item label={t("job_payments.titles.amount")}>
|
||||||
<Descriptions.Item label="Date of Payment">
|
{record.amount}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label={t("job_payments.titles.dateOfPayment")}>
|
||||||
{moment(record.created_at).format("YYYY-MM-DD HH:mm:ss")}
|
{moment(record.created_at).format("YYYY-MM-DD HH:mm:ss")}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="Transaction ID">
|
<Descriptions.Item label={t("job_payments.titles.transactionid")}>
|
||||||
{record.transactionid}
|
{record.transactionid}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="Payment Reference ID">
|
<Descriptions.Item label={t("job_payments.titles.paymentid")}>
|
||||||
{payment_response?.response?.paymentreferenceid ?? ""}
|
{payment_response?.response?.paymentreferenceid ?? ""}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="Payment Type">
|
<Descriptions.Item label={t("job_payments.titles.paymenttype")}>
|
||||||
{record.type}
|
{record.type}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
{payment_response && (
|
{payment_response && (
|
||||||
<Descriptions.Item label="Refund Amount">
|
<Descriptions.Item label={t("job_payments.titles.refundamount")}>
|
||||||
<InputNumber
|
<InputNumber
|
||||||
onChange={setRefundAmount}
|
onChange={setRefundAmount}
|
||||||
max={max_refundable_amount}
|
max={max_refundable_amount}
|
||||||
@@ -135,7 +159,7 @@ const PaymentExpandedRowComponent = ({ record }) => {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<Button onClick={() => showConfirm(payment_response)}>
|
<Button onClick={() => showConfirm(payment_response)}>
|
||||||
Refund Payment
|
{t("job_payments.buttons.refundpayment")}
|
||||||
</Button>
|
</Button>
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -956,6 +956,30 @@
|
|||||||
"priorsuccesfulexport": "This record has previously been exported successfully. Please make sure it has already been deleted in the target system."
|
"priorsuccesfulexport": "This record has previously been exported successfully. Please make sure it has already been deleted in the target system."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"job_payments": {
|
||||||
|
"buttons": {
|
||||||
|
"refundpayment": "Refund Payment",
|
||||||
|
"proceedtopayment": "Proceed to Payment",
|
||||||
|
"goback": "Go Back"
|
||||||
|
},
|
||||||
|
"titles": {
|
||||||
|
"descriptions": "Payment Details",
|
||||||
|
"payer": "Payer",
|
||||||
|
"payername": "Payer Name",
|
||||||
|
"amount": "Amount",
|
||||||
|
"dateOfPayment": "Date of Payment",
|
||||||
|
"transactionid": "Transaction ID",
|
||||||
|
"paymentid": "Payment Reference ID",
|
||||||
|
"paymenttype": "Payment Type",
|
||||||
|
"refundamount": "Refund Amount"
|
||||||
|
},
|
||||||
|
"notifications": {
|
||||||
|
"error": {
|
||||||
|
"title": "Error placing refund",
|
||||||
|
"description": "Please try again. Make sure the refund amount does not exceeds the payment amount."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"general": {
|
"general": {
|
||||||
"actions": {
|
"actions": {
|
||||||
"add": "Add",
|
"add": "Add",
|
||||||
|
|||||||
@@ -244,6 +244,12 @@ app.post(
|
|||||||
intellipay.generate_payment_url
|
intellipay.generate_payment_url
|
||||||
);
|
);
|
||||||
|
|
||||||
|
app.post(
|
||||||
|
"/intellipay/postback",
|
||||||
|
// fb.validateFirebaseIdToken,
|
||||||
|
intellipay.postback
|
||||||
|
);
|
||||||
|
|
||||||
var ioevent = require("./server/ioevent/ioevent");
|
var ioevent = require("./server/ioevent/ioevent");
|
||||||
app.post("/ioevent", ioevent.default);
|
app.post("/ioevent", ioevent.default);
|
||||||
app.post("/newlog", (req, res) => {
|
app.post("/newlog", (req, res) => {
|
||||||
|
|||||||
@@ -104,3 +104,9 @@ exports.generate_payment_url = async (req, res) => {
|
|||||||
res.json({ error });
|
res.json({ error });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.postback = async (req, res) => {
|
||||||
|
console.log("postback as", req.body);
|
||||||
|
|
||||||
|
res.send({ message: "postback" });
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user