diff --git a/src/pages/Payment/Card/index.js b/src/pages/Payment/Card/index.js index 9900418..7294907 100644 --- a/src/pages/Payment/Card/index.js +++ b/src/pages/Payment/Card/index.js @@ -7,10 +7,11 @@ import { } from '@mui/material'; import * as React from "react"; import * as HttpUtils from "utils/HttpUtils"; +import * as UrlUtils from "utils/ApiPathConst"; import { useNavigate } from "react-router-dom"; import { useLocation } from 'react-router-dom'; -import {paymentPath} from "auth/utils"; +// import {paymentPath} from "auth/utils"; // import {poll} from "utils/Utils"; import VisaIcon from "assets/images/icons/visacard.svg"; import MasterIcon from "assets/images/icons/mastercard.svg"; @@ -45,7 +46,7 @@ const Index = () => { // const [fpsqrcodeurl, setFpsqrcodeurl] = React.useState(""); // const pasgPath = 'https://fps.payapps.hkicl.com.hk'; //PRD // const pasgPath = 'https://sim.fps.payapps.hkicl.com.hk'; //Testing - const loadPaymentUrl = "/api/payment/web/"; + // const loadPaymentUrl = "/api/payment/web/"; // const paymentStatusApi = "/api/payment/status/"; // const payloadUrl = "/api/payment/wallet/fps/enquiryfpspayload/"; // const receiverUrl = "/noti-api/payment/payment-notification"; @@ -74,7 +75,7 @@ const Index = () => { localStorage.setItem("webtoken", paymentData.webtoken) HttpUtils.post({ - url: paymentPath+loadPaymentUrl+(paymentData.type=="PPS"?"pps":"creditcard"), + url: UrlUtils.LOAD_PAYMENT_URL+(paymentData.type=="PPS"?"pps":"creditcard"), params:{ "transactionid": paymentData.transactionid, //"apprefid:": paymentData.transactionid, diff --git a/src/pages/Payment/Details_GLD/PaymentDetails.js b/src/pages/Payment/Details_GLD/PaymentDetails.js index 22e45b0..1262bb5 100644 --- a/src/pages/Payment/Details_GLD/PaymentDetails.js +++ b/src/pages/Payment/Details_GLD/PaymentDetails.js @@ -32,7 +32,7 @@ const PaymentDetails = ({ formData,doPrint,onDownload }) => { }, [data]); const getPaymentMethod=()=>{ - let paymentmethod = data.payload.paymentdetail.paymentmethod; + let paymentmethod = data.payload?.paymentdetail.paymentmethod; if("01" == paymentmethod) return "PPS"; if("02" == paymentmethod || "03" == paymentmethod) return "Credit Card"; if("04" == paymentmethod) return "FPS"; diff --git a/src/pages/Payment/Details_Public/PaymentDetails.js b/src/pages/Payment/Details_Public/PaymentDetails.js index 66dc04b..219d537 100644 --- a/src/pages/Payment/Details_Public/PaymentDetails.js +++ b/src/pages/Payment/Details_Public/PaymentDetails.js @@ -24,21 +24,31 @@ const PaymentDetails = ({ formData,doPrint,onDownload }) => { React.useEffect(() => { if (formData != null && formData != undefined && Object.keys(formData).length > 0) { + console.log(formData) setData(formData); } }, [formData]); - + React.useEffect(() => { - if (formData != null && formData != undefined && Object.keys(formData).length > 0) { + if (data != null && data != undefined && Object.keys(data).length > 0) { + console.log(data) setOnReady(data != {}); } }, [data]); const getPaymentMethod=()=>{ - let paymentmethod = data?.payload?.paymentdetail?.paymentmethod; - if("01" == paymentmethod) return "PPS"; - if("02" == paymentmethod || "03" == paymentmethod) return "Credit Card"; - if("04" == paymentmethod) return "FPS"; + let paymentmethod = "" + if (data?.payload!=null) { + paymentmethod = data.payload?.paymentdetail.paymentmethod; + if("01" == paymentmethod) return "PPS"; + if("02" == paymentmethod || "03" == paymentmethod) return "Credit Card"; + if("04" == paymentmethod) return "FPS"; + } else { + paymentmethod = data.payMethod; + if("01,PPSB,PPS" == paymentmethod) return "PPS"; + if("02,BCMP,CreditCard" == paymentmethod || "03,BCMP,CreditCard" == paymentmethod) return "Credit Card"; + if("04,BCFP,FPS" == paymentmethod) return "FPS"; + } return paymentmethod; } @@ -85,7 +95,7 @@ const PaymentDetails = ({ formData,doPrint,onDownload }) => { - {data.payload?.transactionid} + {data.payload?.transactionid?data.payload?.transactionid:data.transNo} @@ -141,7 +151,7 @@ const PaymentDetails = ({ formData,doPrint,onDownload }) => { - {"HK$ " + FormatUtils.currencyFormat(data.payload?.amount)} + {"HK$ " + FormatUtils.currencyFormat(data.payload?.amount?data.payload?.amount:data.payAmount)} diff --git a/src/pages/Payment/Details_Public/index.js b/src/pages/Payment/Details_Public/index.js index 5407daf..68c1cae 100644 --- a/src/pages/Payment/Details_Public/index.js +++ b/src/pages/Payment/Details_Public/index.js @@ -36,8 +36,10 @@ const Index = () => { const params = useParams(); const navigate = useNavigate() const intl = useIntl(); + const [responeData, setResponeData] = React.useState({}); + const [transactionData, setTransactionData] = React.useState({}); - const [record, setRecord] = React.useState(); + const [record, setRecord] = React.useState({}); const [itemList, setItemList] = React.useState([]); const [onReady, setOnReady] = React.useState(false); const [onDownload, setOnDownload] = React.useState(false); @@ -46,13 +48,23 @@ const Index = () => { React.useEffect(() => { loadForm(); - // window.addEventListener('resize', handleResize) }, []); React.useEffect(() => { - setOnReady(true); - }, [record]); + if (Object.keys(responeData).length > 0) { + setTransactionData(responeData); + } + }, [responeData]); + + React.useEffect(() => { + if (Object.keys(transactionData).length > 0) { + console.log(transactionData) + console.log(itemList) + console.log(record) + setOnReady(true); + } + }, [transactionData]); // const handleResize = () => { // setDetailsOrder(window.innerWidth > 1023 ? 2 : -1); @@ -77,17 +89,39 @@ const Index = () => { const loadForm = () => { if (params.id > 0) { - HttpUtils.get({ url: UrlUtils.PAYMENT_LOAD + "/" + params.id, onSuccess: (responseData) => { if (!responseData.data?.id) { navigate("/paymentPage/search"); } - responseData.data["transDateStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "DD/MM/YYYY"); - responseData.data["transTimeStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "HH:mm:ss"); - setItemList(responseData.paymentItemList) - setRecord(responseData.data); + if(responseData.data.status==null||responseData.data.status=="INPR"){ + HttpUtils.post({ + url: UrlUtils.PAYMENT_RETRY_STATUS_API, + params:{ + "paymentId": params.id + }, + onSuccess: function(responseData2){ + responseData2.data["transDateStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "DD/MM/YYYY"); + responseData2.data["transTimeStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "HH:mm:ss"); + setResponeData(responseData2.transactionData) + setItemList(responseData2.paymentItemList) + setRecord(responseData2.data); + }, + onError: function(){ + responseData.data["transDateStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "DD/MM/YYYY"); + responseData.data["transTimeStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "HH:mm:ss"); + setResponeData(responseData) + + } + }); + }else{ + responseData.data["transDateStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "DD/MM/YYYY"); + responseData.data["transTimeStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "HH:mm:ss"); + setResponeData(responseData) + setItemList(responseData.paymentItemList) + setRecord(responseData.data); + } } }); } diff --git a/src/pages/Payment/FPS/AckPage.js b/src/pages/Payment/FPS/AckPage.js index a9b01a7..60e2b68 100644 --- a/src/pages/Payment/FPS/AckPage.js +++ b/src/pages/Payment/FPS/AckPage.js @@ -12,8 +12,8 @@ import * as HttpUtils from "utils/HttpUtils"; import * as UrlUtils from "utils/ApiPathConst"; // import { useNavigate } from "react-router-dom"; // import FpsIcon from "assets/images/icons/fps.svg"; -// import { useLocation } from 'react-router-dom'; -import {paymentPath} from "auth/utils"; +import { useLocation } from 'react-router-dom'; +// import {paymentPath} from "auth/utils"; // import {poll} from "utils/Utils"; import * as DateUtils from "utils/DateUtils" @@ -38,10 +38,11 @@ const BackgroundHead = { const AckPage = () => { // const navigate = useNavigate() - // const location = useLocation(); + const location = useLocation(); // const [locationData, setLocationData] = React.useState({}); const [paymentData, setPaymentData] = React.useState({}); + const [locationData, setLocationData] = React.useState({}); const [responeData, setResponeDataData] = React.useState({}); const [itemList, setItemList] = React.useState([]); // const [paymentId, setPaymentId] = React.useState(""); @@ -50,17 +51,25 @@ const AckPage = () => { // const [transactionDate, setTransactionDate] = React.useState(""); // const [transactionTime, setTransactionTime] = React.useState(""); const [onReady, setOnReady] = React.useState(false); - const paymentStatusApi = "/api/payment/status/"; + // const paymentStatusApi = "/api/payment/status/"; const [onDownload, setOnDownload] = React.useState(false); const intl = useIntl(); const { locale } = intl; React.useEffect(() => { - loadForm(); + if (location.state != undefined) { + setLocationData(location.state) + } }, []); React.useEffect(() => { - console.log(responeData) + if (Object.keys(locationData).length > 0){ + loadForm(); + } + }, [locationData]); + + React.useEffect(() => { + // console.log(responeData) if(Object.keys(responeData).length > 0){ setTransactionData(responeData) } @@ -68,7 +77,7 @@ const AckPage = () => { React.useEffect(() => { // console.log(paymentData) - console.log(transactionData) + // console.log(transactionData) if(Object.keys(transactionData).length > 0 ){ setOnReady(true); } @@ -81,41 +90,49 @@ const AckPage = () => { // const trnTime = date.getHours()+":"+date.getMinutes()+":"+date.getSeconds(); // setTransactionDate(trnDate) // setTransactionTime(trnTime) - let transactionid = localStorage.getItem("transactionid") - let webtoken = localStorage.getItem("webtoken") - + // let transactionid = localStorage.getItem("transactionid") + // let webtoken = localStorage.getItem("webtoken") + let transactionid = locationData.transactionid HttpUtils.post({ - url: paymentPath+paymentStatusApi+transactionid, + url: UrlUtils.PAYMENT_CALLBACK_STATUS_API, params:{ "apprefid": transactionid, - "webtoken": webtoken, + // "webtoken": webtoken, + // "paymentId": localStorage.getItem("paymentId"), + "transactionid":Number(transactionid) }, onSuccess: function(responseData){ - setResponeDataData(responseData) - - if (responseData.paymentdetail?.result?.paymentstatuscode === "APPR") { - localStorage.removeItem("webtoken"); - localStorage.removeItem("transactionid"); - } - HttpUtils.post({ - url: UrlUtils.PAYMENT_SAVE, - params: { - id: localStorage.getItem("paymentId"), - transNo: responseData.transactionid, - transDateTime: new Date(responseData.paymentdetail.time).toISOString(), - egisRefNo: responseData.paymentdetail.paymentid, - status: responseData.paymentdetail.result.paymentstatuscode, - payload: responseData - }, - onSuccess: function (responseData2) { - responseData2.data["transDateStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "DD/MM/YYYY"); - responseData2.data["transTimeStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "HH:mm:ss"); - setItemList(responseData2.paymentItemList) - setPaymentData(responseData2.data); - // localStorage.removeItem("paymentId"); - // setPaymentId(responseData2.id) - } - }); + localStorage.removeItem("webtoken"); + localStorage.removeItem("transactionid"); + responseData.data["transDateStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "DD/MM/YYYY"); + responseData.data["transTimeStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "HH:mm:ss"); + setResponeDataData(responseData.transactionData) + setItemList(responseData.paymentItemList) + setPaymentData(responseData.data); + + + // if (responseData.paymentdetail?.result?.paymentstatuscode === "APPR") { + + // } + // HttpUtils.post({ + // url: UrlUtils.PAYMENT_SAVE, + // params: { + // id: localStorage.getItem("paymentId"), + // transNo: responseData.transactionid, + // transDateTime: new Date(responseData.paymentdetail.time).toISOString(), + // egisRefNo: responseData.paymentdetail.paymentid, + // status: responseData.paymentdetail.result.paymentstatuscode, + // payload: responseData + // }, + // onSuccess: function (responseData2) { + // responseData2.data["transDateStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "DD/MM/YYYY"); + // responseData2.data["transTimeStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "HH:mm:ss"); + // setItemList(responseData2.paymentItemList) + // setPaymentData(responseData2.data); + // // localStorage.removeItem("paymentId"); + // // setPaymentId(responseData2.id) + // } + // }); } }); @@ -147,7 +164,8 @@ const AckPage = () => { setOnDownload(true) const local = locale HttpUtils.fileDownload({ - url: UrlUtils.GEN_PAYMENT_RECEIPT+"/"+localStorage.getItem("paymentId")+"/"+local, + // url: UrlUtils.GEN_PAYMENT_RECEIPT+"/"+localStorage.getItem("paymentId")+"/"+local, + url: UrlUtils.GEN_PAYMENT_RECEIPT+"/"+paymentData.data.id+"/"+local, onResponse:()=>{ setOnDownload(false) }, diff --git a/src/pages/Payment/FPS/FPS.js b/src/pages/Payment/FPS/FPS.js index d7864d8..c77ceb2 100644 --- a/src/pages/Payment/FPS/FPS.js +++ b/src/pages/Payment/FPS/FPS.js @@ -7,10 +7,11 @@ import { } from '@mui/material'; import * as React from "react"; import * as HttpUtils from "utils/HttpUtils"; +import * as UrlUtils from "utils/ApiPathConst"; import { useNavigate } from "react-router-dom"; import FpsIcon from "assets/images/icons/fps.svg"; import { useLocation } from 'react-router-dom'; -import {paymentPath} from "auth/utils"; +// import {paymentPath} from "auth/utils"; import {currencyFormat} from "utils/FormatUtils"; // import {poll} from "utils/Utils"; @@ -53,9 +54,9 @@ const Index = () => { const pasgPathPrd = 'https://fps.payapps.hkicl.com.hk'; //PRD const pasgPath = 'https://sim.fps.payapps.hkicl.com.hk'; //Testing - const loadPaymentUrl = "/api/payment/wallet/fps"; - const cancelPaymentUrl = "/api/payment/cancelpayment"; - const paymentStatusApi = "/api/payment/status/"; + // const loadPaymentUrl = "/api/payment/wallet/fps"; + // const cancelPaymentUrl = "/api/payment/cancelpayment"; + // const paymentStatusApi = "/api/payment/status/"; // const payloadUrl = "/api/payment/wallet/fps/enquiryfpspayload/"; // const receiverUrl = "/noti-api/payment/payment-notification"; @@ -115,11 +116,6 @@ const Index = () => { const loadForm = () => { - // const timeoutdatetime = "2023-10-26T09:04:30Z[UTC]" - // const convertedDateString = timeoutdatetime.replace("[UTC]", ""); - // setFpsmerchanttimeoutdatetime(convertedDateString) - // setPaymentid("C202310268000681") - // setPaymentstatuscode("APPR") const webtoken = paymentData.webtoken; const transactionid = paymentData.transactionid; console.log(webtoken) @@ -129,9 +125,8 @@ const Index = () => { localStorage.setItem("transactionid", transactionid) localStorage.setItem("webtoken", webtoken) - HttpUtils.post({ - url: paymentPath+loadPaymentUrl, + url: UrlUtils.LOAD_PAYMENT_FPS_URL, params:{ "transactionid": transactionid, "webtoken": webtoken, @@ -189,29 +184,64 @@ const Index = () => { setFpsqrcodeurl(openPASGUrl) setFpsqrcodeurlPrd(openPASGUrlPrd) setFpsqrcodeurlFps(openPASGUrlPrdFps) - } }); - + + //testing + // const timeoutdatetime = "2024-05-06T11:10:30Z[UTC]" + // const convertedDateString = timeoutdatetime.replace("[UTC]", ""); + // setFpsmerchanttimeoutdatetime(convertedDateString) + // setPaymentId("C202310268000681") + // const responseData= + // { + // "paymentid": "C202310268000681", + // "paymentstatus": "INPR", + // "fpsmerchanttimeoutdatetime": "2024-05-06T11:10:30Z[UTC]", + // "fpsqrcodeimgbase64": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAYAAAB5fY51AAAuyklEQVR4Xu3dfcy/d1nff2IAAAAASUVORK5CYII=", + // "fpsqrcodeurl": "http://127.0.0.1:8080/api/payment/wallet/fps/enquiryfpspayload/vm.JKDDlTOavR3ASviSwUnS1Lw4-" + // } + // setResponeDataData(responseData) + // const parsedUrl = new URL(responseData.fpsqrcodeurl); + // const fpsqrcodeurl = "https://"+window.location.hostname+'/payment'+parsedUrl.pathname; + // const fpsqrcodeurlwithFps = "https://"+"fps."+window.location.hostname+parsedUrl.pathname; + // console.log(parsedUrl) + // console.log(fpsqrcodeurl) + // console.log(fpsqrcodeurlwithFps) + + // const openPASGUrl = pasgPath + '?pay_req_obj=' + encodeURIComponent(fpsqrcodeurl) + '&callback=' + // + encodeURIComponent("https://"+window.location.hostname+ '/paymentPage/fps/fpscallback?TRANSACTION_ID='+transactionid+"&WEB_TOKEN="+webtoken+"&PAYMENT_ID="+localStorage.getItem("paymentId")); + // const openPASGUrlPrd = pasgPathPrd + '?pay_req_obj=' + encodeURIComponent(fpsqrcodeurl) + '&callback=' + // + encodeURIComponent("https://"+window.location.hostname+ '/paymentPage/fps/fpscallback?TRANSACTION_ID='+transactionid+"&WEB_TOKEN="+webtoken+"&PAYMENT_ID="+localStorage.getItem("paymentId")); + // const openPASGUrlPrdFps = pasgPath + '?pay_req_obj=' + encodeURIComponent(fpsqrcodeurlwithFps) + '&callback=' + // + encodeURIComponent("https://"+window.location.hostname+ '/paymentPage/fps/fpscallback?TRANSACTION_ID='+transactionid+"&WEB_TOKEN="+webtoken+"&PAYMENT_ID="+localStorage.getItem("paymentId")); + // setFpsqrcodeurl(openPASGUrl) + // setFpsqrcodeurlPrd(openPASGUrlPrd) + // setFpsqrcodeurlFps(openPASGUrlPrdFps) + } const getPaymentStatus = () => { if(Object.keys(paymentData).length > 0){ HttpUtils.post({ - url: paymentPath+paymentStatusApi+paymentData.transactionid, + url: UrlUtils.PAYMENT_STATUS_API, params:{ "apprefid": paymentData.transactionid, - "webtoken": paymentData.webtoken, + // "webtoken": paymentData.webtoken, + "transactionid":Number(paymentData.transactionid) }, onSuccess: function(responseData){ const paymentstatuscode = responseData.paymentdetail.result.paymentstatuscode; if (paymentstatuscode != "" && paymentstatuscode != "INPR" ){ if (paymentstatuscode === 'APPR') { // const timestamp = Date.now(); - navigate('/paymentPage/fps/ackpage'); + let page = '/paymentPage/fps/ackpage'; + let stateParams = { state: { transactionid: paymentData.transactionid} } + navigate(page, stateParams); } else if (paymentstatuscode === 'CANC') { // const timestamp = Date.now(); - navigate('/paymentPage/fps/ackpage'); + let page = '/paymentPage/fps/ackpage'; + let stateParams = { state: { transactionid: paymentData.transactionid} } + navigate(page, stateParams); } else { // window.top.location.href = paymentPath + payment.config.errPagePath; alert("ERROR") @@ -237,7 +267,7 @@ const Index = () => { // console.log(timeOutDate.getTime()-currentTime.getTime()) getPaymentStatus(); if (timeOutDate.getTime() { const cancelPayment = ()=>{ if (Object.keys(paymentData).length>0){ HttpUtils.post({ - url: paymentPath+cancelPaymentUrl, + url: UrlUtils.CANCEL_PAYMENT_URL, params:{ "transactionid": paymentData.transactionid, "webtoken": paymentData.webtoken, "paymentid": fpsTransctionData.paymentid }, onSuccess: function(){ - navigate('/paymentPage/fps/ackpage'); + // navigate('/paymentPage/fps/ackpage'); + let page = '/paymentPage/fps/ackpage'; + let stateParams = { state: { transactionid: paymentData.transactionid} } + navigate(page, stateParams); } }); } diff --git a/src/pages/Payment/FPS/fpscallback.js b/src/pages/Payment/FPS/fpscallback.js index 6120c7c..945acdd 100644 --- a/src/pages/Payment/FPS/fpscallback.js +++ b/src/pages/Payment/FPS/fpscallback.js @@ -86,10 +86,12 @@ const Fpscallback = () => { console.log(paymentId) HttpUtils.post({ - url: UrlUtils.PAYMENT_STATUS_API+transactionid, + url: UrlUtils.PAYMENT_CALLBACK_STATUS_API, params:{ "apprefid": transactionid, - "webtoken": webtoken, + "webtoken": webtoken, + "paymentId": paymentId, + "transactionid":Number(transactionid) }, onSuccess: function(responseData){ setResponeDataData(responseData) @@ -97,24 +99,11 @@ const Fpscallback = () => { localStorage.removeItem("webtoken"); localStorage.removeItem("transactionid"); } - HttpUtils.post({ - url: UrlUtils.PAYMENT_SAVE, - params: { - id: paymentId, - transNo: responseData.transactionid, - transDateTime: new Date(responseData.paymentdetail.time).toISOString(), - egisRefNo: responseData.paymentdetail.paymentid, - status: responseData.paymentdetail.result.paymentstatuscode, - payload: responseData - }, - onSuccess: function (responseData2) { - responseData2.data["transDateStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "DD/MM/YYYY"); - responseData2.data["transTimeStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "HH:mm:ss"); - setItemList(responseData2.paymentItemList) - setPaymentData(responseData2.data); - // localStorage.removeItem("paymentId"); - } - }); + responseData.data["transDateStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "DD/MM/YYYY"); + responseData.data["transTimeStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "HH:mm:ss"); + setResponeDataData(responseData.transactionData) + setItemList(responseData.paymentItemList) + setPaymentData(responseData.data); } }); diff --git a/src/pages/Payment/MultiPaymentWindow.js b/src/pages/Payment/MultiPaymentWindow.js index 46c6610..cabe46a 100644 --- a/src/pages/Payment/MultiPaymentWindow.js +++ b/src/pages/Payment/MultiPaymentWindow.js @@ -216,7 +216,9 @@ const MultiPaymentWindow = (props) => { }); const latestDataObjects = Object.values(latestData); - const filteredData = latestDataObjects.filter(item => item.timeDiff > 30 || item.status !== "APPR"); + // const filteredData = latestDataObjects.filter(item => item.timeDiff > 20 || item.status !== "APPR"); + const filteredData = latestDataObjects.filter(item => item.timeDiff > 30 || item.status == "CANC" || item.status == "REJT"); + const filteredAppIds = filteredData.map(item => item.appId); const appIdsNotInData = appIdList.filter(appId => !latestDataObjects.some(item => item.appId === appId)); diff --git a/src/pages/Payment/PaymentCallback.js b/src/pages/Payment/PaymentCallback.js index 0beac0b..d0344f2 100644 --- a/src/pages/Payment/PaymentCallback.js +++ b/src/pages/Payment/PaymentCallback.js @@ -11,7 +11,7 @@ import * as React from "react"; import * as HttpUtils from "utils/HttpUtils"; import * as UrlUtils from "utils/ApiPathConst"; //import { useNavigate } from 'react-router-dom'; -import { paymentPath } from "auth/utils"; +// import { paymentPath } from "auth/utils"; import * as DateUtils from "utils/DateUtils" import Loadable from 'components/Loadable'; @@ -46,8 +46,8 @@ const Index = () => { // const [transactionDate, setTransactionDate] = React.useState(""); // const [transactionTime, setTransactionTime] = React.useState(""); const [onReady, setOnReady] = React.useState(false); - const updatePaymentApi = "/api/payment/updatepayment"; - const paymentStatusApi = "/api/payment/status/"; + // const updatePaymentApi = "/api/payment/updatepayment"; + // const paymentStatusApi = "/api/payment/status/"; const intl = useIntl(); const { locale } = intl; @@ -57,15 +57,17 @@ const Index = () => { }, []); React.useEffect(() => { - console.log(responeData) if (Object.keys(responeData).length > 0) { + console.log(responeData) setTransactionData(responeData) } }, [responeData]); React.useEffect(() => { - console.log(transactionData) if (Object.keys(transactionData).length > 0) { + console.log(transactionData) + console.log(itemList) + console.log(paymentData) setOnReady(true); } }, [transactionData]); @@ -81,7 +83,7 @@ const Index = () => { let receipt_token = params.get("RECEIPT_TOKEN").replace("%3D", "=") HttpUtils.post({ - url: paymentPath + updatePaymentApi, + url: UrlUtils.UPDATE_PAYMENT_API, params: { "transactionid": transactionid, "receipttoken": receipt_token, @@ -109,36 +111,45 @@ const Index = () => { // ) HttpUtils.post({ - url: paymentPath + paymentStatusApi + transactionid, + url: UrlUtils.PAYMENT_CALLBACK_STATUS_API, params: { "apprefid": transactionid, - "webtoken": localStorage.getItem("webtoken"), + // "webtoken": localStorage.getItem("webtoken"), + // "paymentId": localStorage.getItem("paymentId"), + "transactionid":Number(transactionid) }, onSuccess: function (responseData) { - setResponeDataData(responseData) if (responseData.paymentdetail?.result?.paymentstatuscode === "APPR") { localStorage.removeItem("webtoken"); localStorage.removeItem("transactionid"); } - HttpUtils.post({ - url: UrlUtils.PAYMENT_SAVE, - params: { - id: localStorage.getItem("paymentId"), - transNo: responseData.transactionid, - transDateTime: new Date(responseData.paymentdetail.time).toISOString(), - egisRefNo: responseData.paymentdetail.paymentid, - status: responseData.paymentdetail.result.paymentstatuscode, - payload: responseData - }, - onSuccess: function (responseData2) { - responseData2.data["transDateStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "DD/MM/YYYY"); - responseData2.data["transTimeStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "HH:mm:ss"); - setItemList(responseData2.paymentItemList) - setPaymentData(responseData2.data); - // localStorage.removeItem("paymentId"); - // setPaymentId(responseData2.id) - } - }); + responseData.data["transDateStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "DD/MM/YYYY"); + responseData.data["transTimeStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "HH:mm:ss"); + setResponeDataData(responseData.transactionData) + setItemList(responseData.paymentItemList) + setPaymentData(responseData.data); + // if (responseData.paymentdetail?.result?.paymentstatuscode === "APPR") { + + // } + // HttpUtils.post({ + // url: UrlUtils.PAYMENT_SAVE, + // params: { + // id: localStorage.getItem("paymentId"), + // transNo: responseData.transactionid, + // transDateTime: new Date(responseData.paymentdetail.time).toISOString(), + // egisRefNo: responseData.paymentdetail.paymentid, + // status: responseData.paymentdetail.result.paymentstatuscode, + // payload: responseData + // }, + // onSuccess: function (responseData2) { + // responseData2.data["transDateStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "DD/MM/YYYY"); + // responseData2.data["transTimeStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "HH:mm:ss"); + // setItemList(responseData2.paymentItemList) + // setPaymentData(responseData2.data); + // // localStorage.removeItem("paymentId"); + // // setPaymentId(responseData2.id) + // } + // }); } }); } @@ -151,7 +162,8 @@ const Index = () => { const local = locale // console.log(local) HttpUtils.fileDownload({ - url: UrlUtils.GEN_PAYMENT_RECEIPT+"/"+localStorage.getItem("paymentId")+"/"+local, + // url: UrlUtils.GEN_PAYMENT_RECEIPT+"/"+localStorage.getItem("paymentId")+"/"+local, + url: UrlUtils.GEN_PAYMENT_RECEIPT+"/"+paymentData.data.id+"/"+local, onResponse:()=>{ setOnDownload(false) }, diff --git a/src/pages/Payment/Search_Public/DataGrid.js b/src/pages/Payment/Search_Public/DataGrid.js index fb6e2bb..af2f741 100644 --- a/src/pages/Payment/Search_Public/DataGrid.js +++ b/src/pages/Payment/Search_Public/DataGrid.js @@ -76,7 +76,8 @@ export default function SearchPublicNoticeTable({ searchCriteria }) { width: isMdOrLg ? 'auto' : 160, flex: isMdOrLg ? 1 : undefined, valueGetter: (params) => { - return DateUtils.dateStr(params?.value); + // console.log(params) + return DateUtils.dateStr(params?.value?params.value:params.row.created); } }, { diff --git a/src/pages/Payment/index.js b/src/pages/Payment/index.js index 9c55676..82c4e31 100644 --- a/src/pages/Payment/index.js +++ b/src/pages/Payment/index.js @@ -155,7 +155,8 @@ const Index = () => { transNo: transactionData.transactionid, payMethod: paymentMethod, payAmount: totalAmount, - appIdList: location.state?.appIdList ?? [] + appIdList: location.state?.appIdList ?? [], + webtoken: transactionData.webtoken }, onSuccess: function (responData) { localStorage.removeItem("paymentId"); @@ -166,7 +167,7 @@ const Index = () => { }); } - //For testing + // For testing // if (paymentMethod != "") { // HttpUtils.post({ // url: UrlUtils.PAYMENT_CREATE, @@ -174,7 +175,9 @@ const Index = () => { // transNo: "test0002", // payMethod: paymentMethod, // payAmount: totalAmount, - // appIdList: location.state?.appIdList ?? [] + // appIdList: location.state?.appIdList ?? [], + // webtoken: "test000234123412341234123412354212312412341234124123124124124123124123124124" + // }, // onSuccess: function (responData) { // localStorage.removeItem("paymentId"); diff --git a/src/pages/Proof/Payment/Pay.js b/src/pages/Proof/Payment/Pay.js index 4eaeb48..af855b6 100644 --- a/src/pages/Proof/Payment/Pay.js +++ b/src/pages/Proof/Payment/Pay.js @@ -61,8 +61,10 @@ const Index = ({ record }) => { } }); const latestDataObjects = Object.values(latestData); + + // const filteredData = latestDataObjects.filter(item => item.timeDiff > 20 || item.status !== "APPR"); + const filteredData = latestDataObjects.filter(item => item.timeDiff > 30 || item.status == "CANC" || item.status == "REJT"); - const filteredData = latestDataObjects.filter(item => item.timeDiff > 30 || item.status !== "APPR"); const filteredAppIds = filteredData.map(item => item.appId); const appIdsNotInData = appIdList.filter(appId => !latestDataObjects.some(item => item.appId === appId)); diff --git a/src/pages/PublicNotice/Details_Public/ApplicationDetailCard.js b/src/pages/PublicNotice/Details_Public/ApplicationDetailCard.js index 241ede2..a305043 100644 --- a/src/pages/PublicNotice/Details_Public/ApplicationDetailCard.js +++ b/src/pages/PublicNotice/Details_Public/ApplicationDetailCard.js @@ -142,7 +142,9 @@ const ApplicationDetailCard = ( }); const latestDataObjects = Object.values(latestData); - const filteredData = latestDataObjects.filter(item => item.timeDiff > 30 || item.status !== "APPR"); + // const filteredData = latestDataObjects.filter(item => item.timeDiff > 20 || item.status !== "APPR"); + const filteredData = latestDataObjects.filter(item => item.timeDiff > 30 || item.status == "CANC" || item.status == "REJT"); + const filteredAppIds = filteredData.map(item => item.appId); const appIdsNotInData = appIdList.filter(appId => !latestDataObjects.some(item => item.appId === appId)); diff --git a/src/pages/PublicNotice/ListPanel/PendingPaymentTab.js b/src/pages/PublicNotice/ListPanel/PendingPaymentTab.js index 33b8a6c..4596a45 100644 --- a/src/pages/PublicNotice/ListPanel/PendingPaymentTab.js +++ b/src/pages/PublicNotice/ListPanel/PendingPaymentTab.js @@ -136,14 +136,15 @@ export default function SubmittedTab({ setCount, url }) { const latestData = {}; responseData.forEach(item => { - const { appId, timeDiff } = item; - if (latestData[appId] === undefined || timeDiff < latestData[appId].timeDiff) { - latestData[appId] = item; - } + // console.log(item) + const { appId, timeDiff } = item; + if (latestData[appId] === undefined || timeDiff < latestData[appId].timeDiff) { + latestData[appId] = item; + } }); const latestDataObjects = Object.values(latestData); - - const filteredData = latestDataObjects.filter(item => item.timeDiff > 30 || item.status !== "APPR"); + + const filteredData = latestDataObjects.filter(item => item.timeDiff > 30 || item.status == "CANC" || item.status == "REJT"); const filteredAppIds = filteredData.map(item => item.appId); const appIdsNotInData = appIdList.filter(appId => !latestDataObjects.some(item => item.appId === appId)); diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index 42fc32c..43f6dd8 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -1,4 +1,7 @@ -import {apiPath, paymentPath} from "../auth/utils"; +import { + apiPath, + // paymentPath +} from "../auth/utils"; // GET request export const REFRESH_TOKEN = "/refresh-token" @@ -158,9 +161,20 @@ export const PAYMENT_APP_LIST = apiPath+'/payment/applist';//POST export const PAYMENT_CHECK = apiPath+'/payment/check-payment';//GET export const PAYMENT_LIMIT_SETTING_LIST = apiPath+'/settings/payment';//GET -export const PAYMENT_AVAILABLE_PAYMENT = paymentPath+'/api/payment/availability';//POST -export const PAYMENT_TRANSACTION_ID = paymentPath+'/api/payment/transaction';//GET -export const PAYMENT_STATUS_API = paymentPath+'/api/payment/status/';//GET +// export const PAYMENT_AVAILABLE_PAYMENT = paymentPath+'/api/payment/availability';//POST +export const PAYMENT_AVAILABLE_PAYMENT = apiPath+'/payment/api/availability';//POST +// export const PAYMENT_TRANSACTION_ID = paymentPath+'/api/payment/transaction';//GET +export const PAYMENT_TRANSACTION_ID = apiPath+'/payment/api/transaction';//GET +// export const PAYMENT_STATUS_API = paymentPath+'/api/payment/status/';//POST +export const PAYMENT_STATUS_API = apiPath+'/payment/api/status';//POST +// export const LOAD_PAYMENT_URL = paymentPath+ "/api/payment/wallet/fps";//POST +export const LOAD_PAYMENT_FPS_URL = apiPath+ "/payment/api/wallet/fps";//POST +// export const CANCEL_PAYMENT_URL = paymentPath+ "/api/payment/cancelpayment";//POST +export const CANCEL_PAYMENT_URL = apiPath+ "/payment/api/cancelpayment";//POST +export const LOAD_PAYMENT_URL = apiPath+ "/payment/api/web/";//POST +export const PAYMENT_CALLBACK_STATUS_API = apiPath+ "/payment/callback/status";//POST +export const PAYMENT_RETRY_STATUS_API = apiPath+ "/payment/paymentdetail/status";//POST +export const UPDATE_PAYMENT_API = apiPath+ "/payment/api/updatepayment";//POST export const DEMAND_NOTE_PREVIEW = apiPath+'/demandNote/preview';//GET export const DEMAND_NOTE_CREATE = apiPath+'/demandNote/create';//POST diff --git a/src/utils/statusUtils/PaymentStatus.js b/src/utils/statusUtils/PaymentStatus.js index 2bf1223..08eae20 100644 --- a/src/utils/statusUtils/PaymentStatus.js +++ b/src/utils/statusUtils/PaymentStatus.js @@ -21,6 +21,6 @@ function getStatus(params) { if(status == "REJT") return REJT; if(status == "CANC") return CANC; if(status == "INPR") return INPR; - return CANC; + return INPR; }