You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

331 rivejä
17 KiB

  1. // material-ui
  2. import {
  3. Grid,
  4. Typography,
  5. Stack,
  6. // Button,
  7. FormLabel,
  8. } from '@mui/material';
  9. import * as React from "react";
  10. import * as HttpUtils from "utils/HttpUtils";
  11. //import { useNavigate } from 'react-router-dom';
  12. import { paymentPath } from "auth/utils";
  13. import Loadable from 'components/Loadable';
  14. const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent')));
  15. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  16. const BackgroundHead = {
  17. backgroundImage: `url(${titleBackgroundImg})`,
  18. width: '100%',
  19. height: '100%',
  20. backgroundSize: 'contain',
  21. backgroundRepeat: 'no-repeat',
  22. backgroundColor: '#0C489E',
  23. backgroundPosition: 'right'
  24. }
  25. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  26. const Index = () => {
  27. //const navigate = useNavigate()
  28. const [responeData, setResponeDataData] = React.useState({});
  29. const [transactionData, setTransactionData] = React.useState({});
  30. const [transactionDate, setTransactionDate] = React.useState("");
  31. const [transactionTime, setTransactionTime] = React.useState("");
  32. const [onReady, setOnReady] = React.useState(false);
  33. const updatePaymentApi = "/api/payment/updatepayment";
  34. //const paymentStatusApi = "/api/payment/status/";
  35. React.useEffect(() => {
  36. console.log("webtoken: " + localStorage.getItem("webtoken"));
  37. if (localStorage.getItem("webtoken") != null && localStorage.getItem("webtoken") != "") {
  38. loadForm();
  39. }
  40. // else{
  41. // navigate("/dashboard");
  42. // }
  43. }, []);
  44. React.useEffect(() => {
  45. console.log(responeData)
  46. if (Object.keys(responeData).length > 0) {
  47. setTransactionData(responeData)
  48. }
  49. }, [responeData]);
  50. React.useEffect(() => {
  51. console.log(transactionData)
  52. if (Object.keys(transactionData).length > 0) {
  53. setOnReady(true);
  54. }
  55. }, [transactionData]);
  56. const loadForm = () => {
  57. const date = new Date();
  58. const trnDate = date.getDate() + "/" + date.getMonth() + "/" + date.getFullYear();
  59. const trnTime = date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
  60. setTransactionDate(trnDate)
  61. setTransactionTime(trnTime)
  62. const params = new URLSearchParams(window.location.search);
  63. let transactionid = params.get("TRANSACTION_ID")
  64. let receipt_token = params.get("RECEIPT_TOKEN").replace("%3D", "=")
  65. HttpUtils.post({
  66. url: paymentPath + updatePaymentApi,
  67. params: {
  68. "transactionid": transactionid,
  69. "receipttoken": receipt_token,
  70. },
  71. onSuccess: function (responseData) {
  72. // {
  73. // "transactionid": "<transactionid>",
  74. // "currencycode":"<currencycode>",
  75. // "amount":<amount>,
  76. // "paymentdetail":{
  77. // "paymentid": "<paymentid>",
  78. // "paymentmethod": "<paymentmethod>",
  79. // "time": "<time>",
  80. // "brandname": "<brandname>",
  81. // "channel": "<channeltype>",
  82. // "subtype": "<subtype>",
  83. // "attemptno": "<attemptno>",
  84. // "result": {
  85. // "code": "<code>",
  86. // "paymentstatuscode":
  87. // "<paymentstatuscode>"
  88. // "description": "<description>",
  89. // "rejectreasoncode":
  90. // "<rejectreasoncode>",
  91. // "canretry": "<retry>"
  92. // }
  93. // }
  94. //}
  95. setResponeDataData(responseData)
  96. if (responseData.paymentdetail?.result?.paymentstatuscode === "APPR") {
  97. localStorage.removeItem("webtoken");
  98. localStorage.removeItem("transactionid");
  99. }
  100. // HttpUtils.post({
  101. // url: paymentPath + paymentStatusApi + transactionid,
  102. // params: {
  103. // "apprefid": transactionid,
  104. // "webtoken": localStorage.getItem("webtoken"),
  105. // },
  106. // onSuccess: function (responseData) {
  107. // }
  108. // });
  109. }
  110. });
  111. }
  112. return (
  113. !onReady ?
  114. <LoadingComponent />
  115. :
  116. transactionData.paymentdetail?.result?.paymentstatuscode === "APPR" ?
  117. (
  118. <Grid container sx={{ minHeight: '110vh', backgroundColor: '#fff' }} direction="column" justifyContent="flex-start" alignItems="center" >
  119. <Grid item xs={12} width="100%">
  120. <div style={BackgroundHead} width="100%">
  121. <Stack direction="row" height='70px'>
  122. <Typography ml={15} color='#FFF' variant="h4" sx={{ pt: 2 }}>公共啟事:付款成功</Typography>
  123. </Stack>
  124. </div>
  125. </Grid>
  126. {/*row 1*/}
  127. <Grid item xs={12} md={12} >
  128. <Grid container justifyContent="flex-start" alignItems="center" >
  129. <center>
  130. <Grid item xs={12} md={12} >
  131. <Typography variant="h3" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "center" }}>
  132. 您的申請和付款已收到
  133. </Typography>
  134. <Grid container>
  135. <Grid item xs={12} md={12}>
  136. <Grid container >
  137. <Grid item>
  138. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  139. 交易參考號:
  140. </FormLabel>
  141. </Grid>
  142. <Grid item>
  143. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  144. {"P"+transactionData.transactionid}
  145. </FormLabel>
  146. </Grid>
  147. </Grid>
  148. </Grid>
  149. <Grid item xs={12} md={12}>
  150. <Grid container >
  151. <Grid item>
  152. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  153. 交易日期:
  154. </FormLabel>
  155. </Grid>
  156. <Grid item>
  157. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  158. {transactionDate + " (DD/MM/YYYY)"}
  159. </FormLabel>
  160. </Grid>
  161. </Grid>
  162. </Grid>
  163. <Grid item xs={12} md={12}>
  164. <Grid container >
  165. <Grid item>
  166. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  167. 交易時間:
  168. </FormLabel>
  169. </Grid>
  170. <Grid item>
  171. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  172. {transactionTime + " (HH:MI:SS)"}
  173. </FormLabel>
  174. </Grid>
  175. </Grid>
  176. </Grid>
  177. <Grid item xs={12} md={12}>
  178. <Grid container >
  179. <Grid item>
  180. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  181. EGIS 參考號:
  182. </FormLabel>
  183. </Grid>
  184. <Grid item>
  185. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  186. {transactionData.transactionid}
  187. </FormLabel>
  188. </Grid>
  189. </Grid>
  190. </Grid>
  191. <Grid item xs={12} md={12}>
  192. <Grid container >
  193. <Grid item>
  194. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  195. 支付金額
  196. </FormLabel>
  197. </Grid>
  198. <Grid item>
  199. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  200. {"HK$ " + transactionData.amount}
  201. </FormLabel>
  202. </Grid>
  203. </Grid>
  204. </Grid>
  205. <Grid item xs={12} md={12}>
  206. <Grid container >
  207. <Grid item>
  208. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  209. 付款方式:
  210. </FormLabel>
  211. </Grid>
  212. <Grid item>
  213. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  214. {transactionData.paymentdetail.brandname??(transactionData.paymentdetail.paymentmethod==="01"?"PPS":"")}
  215. </FormLabel>
  216. </Grid>
  217. </Grid>
  218. </Grid>
  219. </Grid>
  220. </Grid>
  221. </center>
  222. </Grid>
  223. </Grid>
  224. {/*row 2*/}
  225. </Grid >
  226. ) :
  227. (transactionData.paymentdetail?.result?.paymentstatuscode === "CANC" ?
  228. <Grid container sx={{ minHeight: '110vh', backgroundColor: '#fff' }} direction="column" justifyContent="flex-start" alignItems="center" >
  229. <Grid item xs={12} width="100%">
  230. <div style={BackgroundHead} width="100%">
  231. <Stack direction="row" height='70px'>
  232. <Typography ml={15} color='#FFF' variant="h4" sx={{ pt: 2 }}>公共啟事:付款取消</Typography>
  233. </Stack>
  234. </div>
  235. </Grid>
  236. {/*row 1*/}
  237. <Grid item xs={12} md={12} >
  238. <Grid container justifyContent="flex-start" alignItems="center" >
  239. <center>
  240. <Grid item xs={12} md={8} >
  241. <Typography variant="h5" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "left" }}>
  242. 付款取消訊息:
  243. <br /><br />
  244. 您的付款已被取消。我們收到了您的付款請求,但由於某些原因,付款無法完成。請注意以下事項:
  245. <br /><br />
  246. 如果您主動取消了支付,請確認並確保取消是您的意願。
  247. <br />
  248. 如果付款被取消是由於系統問題或其他原因,請您嘗試以下解決方法:
  249. <br /><br />
  250. 檢查您的支付帳戶是否有任何異常或限制。
  251. <br />
  252. 確保您的付款資訊準確無誤。
  253. <br />
  254. 檢查您的網路連線是否正常。
  255. <br /><br />
  256. 如果您需要進一步的協助或有任何疑問,請隨時與我們聯繫,我們將盡快解決您的付款問題。謝謝!
  257. </Typography>
  258. </Grid>
  259. </center>
  260. </Grid>
  261. </Grid>
  262. {/*row 2*/}
  263. </Grid >
  264. :
  265. <Grid container sx={{ minHeight: '110vh', backgroundColor: '#fff' }} direction="column" justifyContent="flex-start" alignItems="center" >
  266. <Grid item xs={12} width="100%">
  267. <div style={BackgroundHead} width="100%">
  268. <Stack direction="row" height='70px'>
  269. <Typography ml={15} color='#FFF' variant="h4" sx={{ pt: 2 }}>公共啟事:付款失敗</Typography>
  270. </Stack>
  271. </div>
  272. </Grid>
  273. {/*row 1*/}
  274. <Grid item xs={12} md={12} >
  275. <Grid container justifyContent="flex-start" alignItems="center" >
  276. <center>
  277. <Grid item xs={12} md={8} >
  278. <Typography variant="h5" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "left" }}>
  279. 付款失敗訊息:
  280. <br /><br />
  281. 親愛的用戶,很遺憾地告訴您,您的付款操作未成功。我們在處理您的付款時遇到了問題。請您仔細檢查以下事項:
  282. <br /><br />
  283. 您的支付帳戶餘額是否足夠。
  284. <br />
  285. 您提供的付款資訊是否準確無誤。
  286. <br />
  287. 請檢查您的網路連線是否正常。
  288. <br /><br />
  289. 如果您已確認以上問題無誤,但付款失敗,請您嘗試以下解決方法:
  290. <br /><br />
  291. 嘗試使用其他付款方式進行付款。
  292. <br />
  293. 檢查您的支付帳戶是否有異常或限制。
  294. <br />
  295. 聯絡我們的客服人員尋求協助。
  296. <br /><br />
  297. 如果您需要進一步的協助或有任何疑問,請隨時與我們聯繫。非常抱歉給您帶來不便,我們將盡快解決您的付款問題。謝謝!
  298. </Typography>
  299. </Grid>
  300. </center>
  301. </Grid>
  302. </Grid>
  303. {/*row 2*/}
  304. </Grid >
  305. )
  306. );
  307. };
  308. export default Index;