Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

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