Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

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