Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

224 rader
11 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 FpsIcon from "assets/images/icons/fps.svg";
  13. import { useLocation } from 'react-router-dom';
  14. import {paymentPath} from "auth/utils";
  15. // import {poll} from "utils/Utils";
  16. import Loadable from 'components/Loadable';
  17. const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent')));
  18. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  19. const BackgroundHead = {
  20. backgroundImage: `url(${titleBackgroundImg})`,
  21. width: '100%',
  22. height: '100%',
  23. backgroundSize: 'contain',
  24. backgroundRepeat: 'no-repeat',
  25. backgroundColor: '#0C489E',
  26. backgroundPosition: 'right'
  27. }
  28. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  29. const AckPage = () => {
  30. // const navigate = useNavigate()
  31. const location = useLocation();
  32. const [paymentData, setPaymentData] = React.useState({});
  33. const [transactionData, setTransactionData] = React.useState({});
  34. const [transactionDate, setTransactionDate] = React.useState("");
  35. const [transactionTime, setTransactionTime] = React.useState("");
  36. const [onReady, setOnReady] = React.useState(false);
  37. const paymentStatusApi = "/api/payment/status/";
  38. const [paymentid, setPaymentid] = React.useState("");
  39. React.useEffect(() => {
  40. if(location.state != undefined){
  41. console.log(location.state)
  42. setPaymentData(location.state)
  43. }
  44. }, []);
  45. React.useEffect(() => {
  46. if(Object.keys(transactionData).length > 0 ){
  47. setOnReady(true);
  48. }
  49. }, [transactionData]);
  50. React.useEffect(() => {
  51. if (Object.keys(paymentData).length > 0){
  52. const dateTime = paymentData.transactionDateTime;
  53. const date = new Date(dateTime);
  54. const trnDate = date.getDate()+"/"+date.getMonth()+"/"+date.getFullYear();
  55. const trnTime = date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
  56. setTransactionDate(trnDate)
  57. setTransactionTime(trnTime)
  58. setPaymentid(paymentData.paymentid)
  59. }
  60. // setTransactionData(
  61. // {
  62. // "amount": 999.99,
  63. // "currencycode": "HKD",
  64. // "paymentdetail": {
  65. // "attemptno": 1,
  66. // "channel": "MobileWallet",
  67. // "paymentid": "C202310268000681",
  68. // "paymentmethod": "04",
  69. // "result": {
  70. // "canretry": "Y",
  71. // "description": "CANC - Cancelled by user or Payment Server.",
  72. // "paymentstatuscode": "CANC",
  73. // "rejectreasoncode": "Payment Cancelled. [PAY-E-9022]"
  74. // },
  75. // "subtype": "FPS",
  76. // "time": "2023-10-26T09:02:17Z[UTC]"
  77. // },
  78. // "transactionid": "20231026170103921"
  79. // }
  80. // )
  81. HttpUtils.post({
  82. url: paymentPath+paymentStatusApi+paymentid,
  83. params:{
  84. "apprefid": paymentData.transactionid,
  85. "webtoken": paymentData.webtoken,
  86. },
  87. onSuccess: function(responseData){
  88. setTransactionData(responseData)
  89. }
  90. });
  91. }, [paymentData]);
  92. return (
  93. !onReady ?
  94. <LoadingComponent />
  95. :
  96. (
  97. <Grid container sx={{ minHeight: '110vh', backgroundColor: '#fff' }} direction="column" justifyContent="flex-start" alignItems="center" >
  98. <Grid item xs={12} width="100%">
  99. <div style={BackgroundHead} width="100%">
  100. <Stack direction="row" height='70px'>
  101. <Typography ml={15} color='#FFF' variant="h4" sx={{ pt: 2 }}>公共啟事:FPS付款</Typography>
  102. </Stack>
  103. </div>
  104. </Grid>
  105. {/*row 1*/}
  106. <Grid item xs={12} md={12} >
  107. <Grid container justifyContent="flex-start" alignItems="center" >
  108. <center>
  109. <Grid item xs={12} md={12} >
  110. <Typography variant="h3" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "center" }}>
  111. Your application and payment have been received
  112. </Typography>
  113. <Grid container>
  114. <Grid item xs={12} md={12}>
  115. <Grid container >
  116. <Grid item>
  117. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  118. Transaction Reference No:
  119. </FormLabel>
  120. </Grid>
  121. <Grid item>
  122. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  123. </FormLabel>
  124. </Grid>
  125. </Grid>
  126. </Grid>
  127. <Grid item xs={12} md={12}>
  128. <Grid container >
  129. <Grid item>
  130. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  131. Transaction Date:
  132. </FormLabel>
  133. </Grid>
  134. <Grid item>
  135. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  136. {transactionDate+" (DD/MM/YYYY)"}
  137. </FormLabel>
  138. </Grid>
  139. </Grid>
  140. </Grid>
  141. <Grid item xs={12} md={12}>
  142. <Grid container >
  143. <Grid item>
  144. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  145. Transaction Time:
  146. </FormLabel>
  147. </Grid>
  148. <Grid item>
  149. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  150. {transactionTime+" (HH:MI:SS)"}
  151. </FormLabel>
  152. </Grid>
  153. </Grid>
  154. </Grid>
  155. <Grid item xs={12} md={12}>
  156. <Grid container >
  157. <Grid item>
  158. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  159. EGIS Reference No:
  160. </FormLabel>
  161. </Grid>
  162. <Grid item>
  163. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  164. {transactionData.transactionid}
  165. </FormLabel>
  166. </Grid>
  167. </Grid>
  168. </Grid>
  169. <Grid item xs={12} md={12}>
  170. <Grid container >
  171. <Grid item>
  172. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  173. Payment Amount
  174. </FormLabel>
  175. </Grid>
  176. <Grid item>
  177. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  178. {"HK$ "+transactionData.amount}
  179. </FormLabel>
  180. </Grid>
  181. </Grid>
  182. </Grid>
  183. <Grid item xs={12} md={12}>
  184. <Grid container >
  185. <Grid item>
  186. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  187. Payment Method:
  188. </FormLabel>
  189. </Grid>
  190. <Grid item>
  191. <FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}>
  192. {transactionData.paymentdetail.subtype}
  193. </FormLabel>
  194. </Grid>
  195. </Grid>
  196. </Grid>
  197. </Grid>
  198. </Grid>
  199. </center>
  200. </Grid>
  201. </Grid>
  202. {/*row 2*/}
  203. </Grid >
  204. )
  205. );
  206. };
  207. export default AckPage;