Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

281 linhas
14 KiB

  1. // material-ui
  2. import {
  3. Grid,
  4. Typography,
  5. Stack,
  6. Box
  7. // Button,
  8. // FormLabel,
  9. } from '@mui/material';
  10. import * as React from "react";
  11. import * as HttpUtils from "utils/HttpUtils";
  12. import * as UrlUtils from "utils/ApiPathConst";
  13. // import { useNavigate } from "react-router-dom";
  14. // import FpsIcon from "assets/images/icons/fps.svg";
  15. // import { useLocation } from 'react-router-dom';
  16. import {paymentPath} from "auth/utils";
  17. // import {poll} from "utils/Utils";
  18. import * as DateUtils from "utils/DateUtils"
  19. import Loadable from 'components/Loadable';
  20. const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent')));
  21. const PaymentDetails = Loadable(React.lazy(() => import('../Details_Public/PaymentDetails')));
  22. const DataGrid = Loadable(React.lazy(() => import('../Details_Public/DataGrid')));
  23. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  24. const BackgroundHead = {
  25. backgroundImage: `url(${titleBackgroundImg})`,
  26. width: '100%',
  27. height: '100%',
  28. backgroundSize: 'contain',
  29. backgroundRepeat: 'no-repeat',
  30. backgroundColor: '#0C489E',
  31. backgroundPosition: 'right'
  32. }
  33. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  34. const Fpscallback = () => {
  35. // const navigate = useNavigate()
  36. // const location = useLocation();
  37. // const [locationData, setLocationData] = React.useState({});
  38. const [paymentData, setPaymentData] = React.useState({});
  39. const [responeData, setResponeDataData] = React.useState({});
  40. const [itemList, setItemList] = React.useState([]);
  41. // const [paymentId, setPaymentId] = React.useState("");
  42. const [transactionData, setTransactionData] = React.useState({});
  43. // const [transactionDate, setTransactionDate] = React.useState("");
  44. // const [transactionTime, setTransactionTime] = React.useState("");
  45. const [onReady, setOnReady] = React.useState(false);
  46. const paymentStatusApi = "/api/payment/status/";
  47. React.useEffect(() => {
  48. loadForm();
  49. }, []);
  50. React.useEffect(() => {
  51. console.log(responeData)
  52. if(Object.keys(responeData).length > 0){
  53. setTransactionData(responeData)
  54. }
  55. }, [responeData]);
  56. React.useEffect(() => {
  57. // console.log(paymentData)
  58. console.log(transactionData)
  59. if(Object.keys(transactionData).length > 0 ){
  60. setOnReady(true);
  61. }
  62. }, [transactionData]);
  63. const loadForm = () => {
  64. const params = new URLSearchParams(window.location.search);
  65. let transactionid = params.get("TRANSACTION_ID")
  66. let webtoken = params.get("WEB_TOKEN")
  67. let paymentId = params.get("PAYMENT_ID")
  68. console.log(transactionid)
  69. console.log(webtoken)
  70. console.log(paymentId)
  71. HttpUtils.post({
  72. url: paymentPath+paymentStatusApi+transactionid,
  73. params:{
  74. "apprefid": transactionid,
  75. "webtoken": webtoken,
  76. },
  77. onSuccess: function(responseData){
  78. setResponeDataData(responseData)
  79. if (responseData.paymentdetail?.result?.paymentstatuscode === "APPR") {
  80. localStorage.removeItem("webtoken");
  81. localStorage.removeItem("transactionid");
  82. }
  83. HttpUtils.post({
  84. url: UrlUtils.PAYMENT_SAVE,
  85. params: {
  86. id: paymentId,
  87. transNo: responseData.transactionid,
  88. transDateTime: responseData.paymentdetail.time.replace("[UTC]", ""),
  89. egisRefNo: responseData.paymentdetail.paymentid,
  90. status: responseData.paymentdetail.result.paymentstatuscode,
  91. payload: responseData
  92. },
  93. onSuccess: function (responseData2) {
  94. responseData2.data["transDateStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "DD/MM/YYYY");
  95. responseData2.data["transTimeStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "HH:mm:ss");
  96. setItemList(responseData2.paymentItemList)
  97. setPaymentData(responseData2.data);
  98. localStorage.removeItem("paymentId");
  99. }
  100. });
  101. }
  102. });
  103. // setTransactionData(
  104. // {
  105. // "amount": 999.99,
  106. // "currencycode": "HKD",
  107. // "paymentdetail": {
  108. // "attemptno": 1,
  109. // "channel": "MobileWallet",
  110. // "paymentid": "C202310268000681",
  111. // "paymentmethod": "04",
  112. // "result": {
  113. // "canretry": "Y",
  114. // "description": "CANC - Cancelled by user or Payment Server.",
  115. // "paymentstatuscode": "CANC",
  116. // "rejectreasoncode": "Payment Cancelled. [PAY-E-9022]"
  117. // },
  118. // "subtype": "FPS",
  119. // "time": "2023-10-26T09:02:17Z[UTC]"
  120. // },
  121. // "transactionid": "20231026170103921"
  122. // }
  123. // )
  124. }
  125. return (
  126. !onReady ?
  127. <LoadingComponent />
  128. :
  129. transactionData.paymentdetail?.result?.paymentstatuscode === "APPR" ?
  130. (
  131. <Grid container sx={{ minHeight: '110vh', backgroundColor: '#fff' }} direction="column" justifyContent="flex-start" alignItems="center" >
  132. <Grid item xs={12} width="100%">
  133. <div style={BackgroundHead} width="100%">
  134. <Stack direction="row" height='70px'>
  135. <Typography ml={15} color='#FFF' variant="h4" sx={{ pt: 2 }}>公共啟事:付款成功</Typography>
  136. </Stack>
  137. </div>
  138. </Grid>
  139. {/*row 1*/}
  140. <Grid item xs={12} md={12} >
  141. <Grid container justifyContent="flex-start" alignItems="center" >
  142. <center>
  143. <Grid item xs={12} md={12} >
  144. <Typography variant="h3" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "center" }}>
  145. 您的申請和付款已收到
  146. </Typography>
  147. <Grid container>
  148. <Grid item xs={12} md={12} sx={{ textAlign: "center" }}>
  149. <Grid container justifyContent="center" spacing={2} sx={{ p: 2 }} alignitems="stretch" >
  150. <Grid item xs={12} md={5} sx={{ pt: 1, pb: 2 }} style={{ height: '100%' }}>
  151. <Box xs={12} md={12} sx={{ p: 4, border: '3px solid #eee', borderRadius: '10px' }} >
  152. <DataGrid
  153. recordList={itemList}
  154. />
  155. </Box>
  156. </Grid>
  157. <Grid item xs={12} md={5} sx={{ pt: 2 }} style={{ height: '100%' }}>
  158. <Box xs={12} md={12} sx={{ p: 4, border: '3px solid #eee', borderRadius: '10px' }} >
  159. <PaymentDetails
  160. formData={paymentData}
  161. style={{
  162. display: "flex",
  163. height: "100%",
  164. flex: 1
  165. }}
  166. />
  167. </Box>
  168. </Grid>
  169. </Grid>
  170. </Grid>
  171. </Grid>
  172. </Grid>
  173. </center>
  174. </Grid>
  175. </Grid>
  176. {/*row 2*/}
  177. </Grid >
  178. ) :
  179. (transactionData.paymentdetail?.result?.paymentstatuscode === "CANC" ?
  180. <Grid container sx={{ minHeight: '110vh', backgroundColor: '#fff' }} direction="column" justifyContent="flex-start" alignItems="center" >
  181. <Grid item xs={12} width="100%">
  182. <div style={BackgroundHead} width="100%">
  183. <Stack direction="row" height='70px'>
  184. <Typography ml={15} color='#FFF' variant="h4" sx={{ pt: 2 }}>公共啟事:付款取消</Typography>
  185. </Stack>
  186. </div>
  187. </Grid>
  188. {/*row 1*/}
  189. <Grid item xs={12} md={12} >
  190. <Grid container justifyContent="flex-start" alignItems="center" >
  191. <center>
  192. <Grid item xs={12} md={8} >
  193. <Typography variant="h5" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "left" }}>
  194. 付款取消訊息:
  195. <br /><br />
  196. 您的付款已被取消。我們收到了您的付款請求,但由於某些原因,付款無法完成。請注意以下事項:
  197. <br /><br />
  198. 如果您主動取消了支付,請確認並確保取消是您的意願。
  199. <br />
  200. 如果付款被取消是由於系統問題或其他原因,請您嘗試以下解決方法:
  201. <br /><br />
  202. 檢查您的支付帳戶是否有任何異常或限制。
  203. <br />
  204. 確保您的付款資訊準確無誤。
  205. <br />
  206. 檢查您的網路連線是否正常。
  207. <br /><br />
  208. 如果您需要進一步的協助或有任何疑問,請隨時與我們聯繫,我們將盡快解決您的付款問題。謝謝!
  209. </Typography>
  210. </Grid>
  211. </center>
  212. </Grid>
  213. </Grid>
  214. {/*row 2*/}
  215. </Grid >
  216. :
  217. <Grid container sx={{ minHeight: '110vh', backgroundColor: '#fff' }} direction="column" justifyContent="flex-start" alignItems="center" >
  218. <Grid item xs={12} width="100%">
  219. <div style={BackgroundHead} width="100%">
  220. <Stack direction="row" height='70px'>
  221. <Typography ml={15} color='#FFF' variant="h4" sx={{ pt: 2 }}>公共啟事:付款失敗</Typography>
  222. </Stack>
  223. </div>
  224. </Grid>
  225. {/*row 1*/}
  226. <Grid item xs={12} md={12} >
  227. <Grid container justifyContent="flex-start" alignItems="center" >
  228. <center>
  229. <Grid item xs={12} md={8} >
  230. <Typography variant="h5" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "left" }}>
  231. 付款失敗訊息:
  232. <br /><br />
  233. 親愛的用戶,很遺憾地告訴您,您的付款操作未成功。我們在處理您的付款時遇到了問題。請您仔細檢查以下事項:
  234. <br /><br />
  235. 您的支付帳戶餘額是否足夠。
  236. <br />
  237. 您提供的付款資訊是否準確無誤。
  238. <br />
  239. 請檢查您的網路連線是否正常。
  240. <br /><br />
  241. 如果您已確認以上問題無誤,但付款失敗,請您嘗試以下解決方法:
  242. <br /><br />
  243. 嘗試使用其他付款方式進行付款。
  244. <br />
  245. 檢查您的支付帳戶是否有異常或限制。
  246. <br />
  247. 聯絡我們的客服人員尋求協助。
  248. <br /><br />
  249. 如果您需要進一步的協助或有任何疑問,請隨時與我們聯繫。非常抱歉給您帶來不便,我們將盡快解決您的付款問題。謝謝!
  250. </Typography>
  251. </Grid>
  252. </center>
  253. </Grid>
  254. </Grid>
  255. {/*row 2*/}
  256. </Grid >
  257. )
  258. );
  259. };
  260. export default Fpscallback;