| @@ -34,7 +34,10 @@ const AckPage = () => { | |||
| // const navigate = useNavigate() | |||
| const location = useLocation(); | |||
| const [locationData, setLocationData] = React.useState({}); | |||
| const [paymentData, setPaymentData] = React.useState({}); | |||
| const [responeData, setResponeDataData] = React.useState({}); | |||
| const [transactionData, setTransactionData] = React.useState({}); | |||
| const [transactionDate, setTransactionDate] = React.useState(""); | |||
| const [transactionTime, setTransactionTime] = React.useState(""); | |||
| @@ -43,13 +46,35 @@ const AckPage = () => { | |||
| const [paymentid, setPaymentid] = React.useState(""); | |||
| React.useEffect(() => { | |||
| console.log(location.state) | |||
| console.log (location.state) | |||
| if(Object.keys(location.state).length > 0){ | |||
| console.log(location.state) | |||
| setPaymentData(location.state) | |||
| console.log (location.state) | |||
| setLocationData(location.state) | |||
| } | |||
| }, []); | |||
| React.useEffect(() => { | |||
| console.log (locationData) | |||
| if (Object.keys(locationData).length > 0){ | |||
| setPaymentData(locationData) | |||
| // loadForm(); | |||
| } | |||
| }, [locationData]); | |||
| React.useEffect(() => { | |||
| console.log (paymentData) | |||
| if (Object.keys(paymentData).length > 0){ | |||
| loadForm(); | |||
| } | |||
| }, [paymentData]); | |||
| React.useEffect(() => { | |||
| console.log(responeData) | |||
| if(Object.keys(responeData).length > 0 && fpsmerchanttimeoutdatetime!=""){ | |||
| setTransactionData(responeData) | |||
| } | |||
| }, [responeData]); | |||
| React.useEffect(() => { | |||
| console.log(paymentData) | |||
| console.log(transactionData) | |||
| @@ -58,26 +83,25 @@ const AckPage = () => { | |||
| } | |||
| }, [transactionData]); | |||
| React.useEffect(() => { | |||
| if (Object.keys(paymentData).length > 0){ | |||
| const dateTime = paymentData.transactionDateTime; | |||
| const date = new Date(dateTime); | |||
| const trnDate = date.getDate()+"/"+date.getMonth()+"/"+date.getFullYear(); | |||
| const trnTime = date.getHours()+":"+date.getMinutes()+":"+date.getSeconds(); | |||
| setTransactionDate(trnDate) | |||
| setTransactionTime(trnTime) | |||
| setPaymentid(paymentData.paymentid) | |||
| HttpUtils.post({ | |||
| url: paymentPath+paymentStatusApi+paymentid, | |||
| params:{ | |||
| "apprefid": paymentData.transactionid, | |||
| "webtoken": paymentData.webtoken, | |||
| }, | |||
| onSuccess: function(responseData){ | |||
| setTransactionData(responseData) | |||
| } | |||
| }); | |||
| } | |||
| const loadForm = () => { | |||
| const dateTime = paymentData.transactionDateTime; | |||
| const date = new Date(dateTime); | |||
| const trnDate = date.getDate()+"/"+date.getMonth()+"/"+date.getFullYear(); | |||
| const trnTime = date.getHours()+":"+date.getMinutes()+":"+date.getSeconds(); | |||
| setTransactionDate(trnDate) | |||
| setTransactionTime(trnTime) | |||
| setPaymentid(paymentData.paymentid) | |||
| HttpUtils.post({ | |||
| url: paymentPath+paymentStatusApi+paymentid, | |||
| params:{ | |||
| "apprefid": paymentData.transactionid, | |||
| "webtoken": paymentData.webtoken, | |||
| }, | |||
| onSuccess: function(responseData){ | |||
| setResponeDataData(responseData) | |||
| } | |||
| }); | |||
| // setTransactionData( | |||
| // { | |||
| // "amount": 999.99, | |||
| @@ -99,8 +123,7 @@ const AckPage = () => { | |||
| // "transactionid": "20231026170103921" | |||
| // } | |||
| // ) | |||
| }, [paymentData]); | |||
| } | |||
| return ( | |||
| !onReady ? | |||
| @@ -37,6 +37,7 @@ const Index = () => { | |||
| const [paymentData, setPaymentData] = React.useState({}); | |||
| const [onReady, setOnReady] = React.useState(false); | |||
| const [responeData, setResponeDataData] = React.useState({}); | |||
| const [fpsTransctionData, setFpsTransctionData] = React.useState({}); | |||
| const [fpsmerchanttimeoutdatetime, setFpsmerchanttimeoutdatetime] = React.useState(""); | |||
| @@ -76,9 +77,16 @@ const Index = () => { | |||
| } | |||
| }, [paymentData]); | |||
| React.useEffect(() => { | |||
| console.log(responeData) | |||
| if(Object.keys(responeData).length > 0 && fpsmerchanttimeoutdatetime!=""){ | |||
| setFpsTransctionData(responeData) | |||
| } | |||
| }, [responeData]); | |||
| React.useEffect(() => { | |||
| console.log(fpsTransctionData) | |||
| if(Object.keys(fpsTransctionData).length > 0 && fpsmerchanttimeoutdatetime!=""){ | |||
| if(Object.keys(fpsTransctionData).length > 0 ){ | |||
| setOnReady(true); | |||
| currentTimer.current = setInterval(() => { | |||
| setTime((prevTime) => prevTime + 1); | |||
| @@ -126,7 +134,7 @@ const Index = () => { | |||
| "fpsqrcodeurl": "<fpsqrcodeurl>" | |||
| } | |||
| */ | |||
| setFpsTransctionData(responseData) | |||
| setResponeDataData(responseData) | |||
| const timeoutdatetime = responseData.fpsmerchanttimeoutdatetime | |||
| const convertedDateString = timeoutdatetime.replace("[UTC]", ""); | |||
| setFpsmerchanttimeoutdatetime(convertedDateString) | |||
| @@ -143,9 +151,8 @@ const Index = () => { | |||
| } | |||
| const getPaymentStatus = () => { | |||
| console.log(fpsTransctionData.paymentstatuscode) | |||
| HttpUtils.post({ | |||
| url: paymentPath+paymentStatusApi+fpsTransctionData.transactionid, | |||
| url: paymentPath+paymentStatusApi+paymentData.transactionid, | |||
| params:{ | |||
| "apprefid": paymentData.transactionid, | |||
| "webtoken": paymentData.webtoken, | |||
| @@ -155,7 +162,7 @@ const Index = () => { | |||
| if (paymentstatuscode != "" && paymentstatuscode != "INPR" ){ | |||
| if (paymentstatuscode === 'APPR') { | |||
| const timestamp = Date.now(); | |||
| navigate('/payment/fps/ackpage', {state:{transactionDateTime:timestamp,transactionid:paymentData.transactionid,webtoken:paymentData.webtoken, paymentid:paymentid} }); | |||
| navigate('/payment/fps/ackpage', {state:{transactionDateTime:timestamp,transactionid:paymentData.transactionid,webtoken:paymentData.webtoken, paymentid:responseData.paymentdetail.paymentid} }); | |||
| } else if (paymentstatuscode === 'CANC') { | |||
| // window.top.location.href = paymentPath + payment.config.indexPagePath; | |||
| navigate('/payment'); | |||
| @@ -167,7 +174,7 @@ const Index = () => { | |||
| }, | |||
| onError: function(){ | |||
| cancelPayment() | |||
| clearInterval(currentTimer.current); | |||
| // clearInterval(currentTimer.current); | |||
| } | |||
| }); | |||
| }; | |||
| @@ -176,10 +183,13 @@ const Index = () => { | |||
| const timeOutDate = new Date(fpsmerchanttimeoutdatetime); | |||
| const currentTime = new Date; | |||
| console.log(time) | |||
| console.log(timeOutDate) | |||
| console.log(currentTime) | |||
| getPaymentStatus(); | |||
| if (timeOutDate.getTime()<currentTime.getTime()){ | |||
| console.log("stop"); | |||
| clearInterval(currentTimer.current); | |||
| cancelPayment() | |||
| } | |||
| },[time]) | |||
| @@ -74,8 +74,8 @@ const Index = () => { | |||
| useEffect(() => { | |||
| if (confirmPayment){ | |||
| setOpen(false); | |||
| let transactionid = ""; | |||
| let webtoken = ""; | |||
| // let transactionid = ""; | |||
| // let webtoken = ""; | |||
| if(selectedPaymentMethod === "FPS"){ | |||
| navigate('/payment/fps', {state:{amount:totalAmount,transactionid:transactionData.transactionid,webtoken:transactionData.webtoken} }); | |||