diff --git a/src/pages/Payment/Card/index.js b/src/pages/Payment/Card/index.js index 7e4662e..3e9e622 100644 --- a/src/pages/Payment/Card/index.js +++ b/src/pages/Payment/Card/index.js @@ -89,8 +89,9 @@ const Index = () => { }, // "locale":"", // "eserviceid":"", - "returnurl": "http://"+window.location.hostname+"/paymentPage/success" + "returnurl": "http://"+window.location.hostname+"/paymentPage/success/"+paymentData.transactionid+"/"+paymentData.webtoken }, + ///{state:{transactionid:paymentData.transactionid,webtoken:paymentData.webtoken} } onSuccess: function(responseData){ /* { diff --git a/src/pages/Payment/FPS/AckPage.js b/src/pages/Payment/FPS/AckPage.js index cc6019a..075ab1d 100644 --- a/src/pages/Payment/FPS/AckPage.js +++ b/src/pages/Payment/FPS/AckPage.js @@ -43,7 +43,6 @@ const AckPage = () => { const [transactionTime, setTransactionTime] = React.useState(""); const [onReady, setOnReady] = React.useState(false); const paymentStatusApi = "/api/payment/status/"; - const [paymentid, setPaymentid] = React.useState(""); React.useEffect(() => { console.log (location.state) @@ -90,9 +89,8 @@ const AckPage = () => { const trnTime = date.getHours()+":"+date.getMinutes()+":"+date.getSeconds(); setTransactionDate(trnDate) setTransactionTime(trnTime) - setPaymentid(paymentData.paymentid) HttpUtils.post({ - url: paymentPath+paymentStatusApi+paymentid, + url: paymentPath+paymentStatusApi+paymentData.transactionid, params:{ "apprefid": paymentData.transactionid, "webtoken": paymentData.webtoken, diff --git a/src/pages/Payment/FPS/FPS.js b/src/pages/Payment/FPS/FPS.js index 0c29705..37167ef 100644 --- a/src/pages/Payment/FPS/FPS.js +++ b/src/pages/Payment/FPS/FPS.js @@ -163,7 +163,7 @@ const Index = () => { if (paymentstatuscode != "" && paymentstatuscode != "INPR" ){ if (paymentstatuscode === 'APPR') { const timestamp = Date.now(); - navigate('/paymentPage/fps/ackpage', {state:{transactionDateTime:timestamp,transactionid:paymentData.transactionid,webtoken:paymentData.webtoken, paymentid:responseData.paymentdetail.paymentid} }); + navigate('/paymentPage/fps/ackpage', {state:{transactionDateTime:timestamp,transactionid:paymentData.transactionid,webtoken:paymentData.webtoken} }); } else if (paymentstatuscode === 'CANC') { // window.top.location.href = paymentPath + payment.config.indexPagePath; navigate('/paymentPage'); diff --git a/src/pages/Payment/PaymentSuccess.js b/src/pages/Payment/PaymentSuccess.js index e7c3282..f9f2bee 100644 --- a/src/pages/Payment/PaymentSuccess.js +++ b/src/pages/Payment/PaymentSuccess.js @@ -3,12 +3,16 @@ import { Grid, Typography, Stack, + // Button, + FormLabel, } from '@mui/material'; -import * as UrlUtils from "utils/ApiPathConst"; import * as React from "react"; import * as HttpUtils from "utils/HttpUtils"; -import { useParams } from "react-router-dom"; -import { useNavigate } from "react-router-dom"; +// import { useNavigate } from "react-router-dom"; +// import FpsIcon from "assets/images/icons/fps.svg"; +import { useParams } from 'react-router-dom'; +import { paymentPath } from "auth/utils"; +// import {poll} from "utils/Utils"; import Loadable from 'components/Loadable'; const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); @@ -27,33 +31,53 @@ const BackgroundHead = { // ==============================|| DASHBOARD - DEFAULT ||============================== // const Index = () => { + // const navigate = useNavigate() const params = useParams(); - const navigate = useNavigate() + const [responeData, setResponeDataData] = React.useState({}); - const [record, setRecord] = React.useState(); + const [transactionData, setTransactionData] = React.useState({}); + const [transactionDate, setTransactionDate] = React.useState(""); + const [transactionTime, setTransactionTime] = React.useState(""); const [onReady, setOnReady] = React.useState(false); + const paymentStatusApi = "/api/payment/status/"; + React.useEffect(() => { - loadForm(); + if (params.transactionid != "" && params.webtoken != "") { + loadForm(); + } }, []); React.useEffect(() => { - setOnReady(true); - }, [record]); + console.log(responeData) + if (Object.keys(responeData).length > 0 && fpsmerchanttimeoutdatetime != "") { + setTransactionData(responeData) + } + }, [responeData]); + React.useEffect(() => { + console.log(transactionData) + if (Object.keys(transactionData).length > 0) { + setOnReady(true); + } + }, [transactionData]); const loadForm = () => { - if (params.id > 0) { - HttpUtils.get({ - url: UrlUtils.GET_PROOF_PAY + "/" + params.id, - onSuccess: (responseData) => { - if (!responseData.data?.id) { - navigate("/proof/search"); - } - setRecord(responseData.data); - } - }); - } + const date = new Date(); + const trnDate = date.getDate() + "/" + date.getMonth() + "/" + date.getFullYear(); + const trnTime = date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); + setTransactionDate(trnDate) + setTransactionTime(trnTime) + HttpUtils.post({ + url: paymentPath + paymentStatusApi + params.transactionid, + params: { + "apprefid": params.transactionid, + "webtoken": params.webtoken, + }, + onSuccess: function (responseData) { + setResponeDataData(responseData) + } + }); } return ( @@ -65,7 +89,7 @@ const Index = () => {
- 公共啟事:完成付款 + 公共啟事:付款成功
@@ -75,20 +99,104 @@ const Index = () => {
- - 付款成功 + + 您的申請和付款已收到 + + + + + + + 交易參考號: + + + + + + + + + + + + + + 交易日期: + + + + + {transactionDate + " (DD/MM/YYYY)"} + + + + + + + + + 交易時間: + + + + + {transactionTime + " (HH:MI:SS)"} + + + + + + + + + EGIS 參考號: + + + + + {transactionData.transactionid} + + + + + + + + + 支付金額 + + + + + {"HK$ " + transactionData.amount} + + + + + + + + + 付款方式: + + + + + {transactionData.paymentdetail.subtype} + + + + +
{/*row 2*/} - - ) - ); }; diff --git a/src/routes/PublicUserRoutes.js b/src/routes/PublicUserRoutes.js index 16158c9..722a0ed 100644 --- a/src/routes/PublicUserRoutes.js +++ b/src/routes/PublicUserRoutes.js @@ -79,7 +79,7 @@ const PublicDashboard = { element: }, { - path: 'paymentPage/success', + path: 'paymentPage/success/:transactionid/:webtoken', element: }, {