瀏覽代碼

fix parm missing

master
Alex Cheung 1 年之前
父節點
當前提交
84b2eed851
共有 3 個文件被更改,包括 66 次插入33 次删除
  1. +48
    -25
      src/pages/Payment/FPS/AckPage.js
  2. +16
    -6
      src/pages/Payment/FPS/FPS.js
  3. +2
    -2
      src/pages/Payment/index.js

+ 48
- 25
src/pages/Payment/FPS/AckPage.js 查看文件

@@ -34,7 +34,10 @@ const AckPage = () => {
// const navigate = useNavigate() // const navigate = useNavigate()
const location = useLocation(); const location = useLocation();


const [locationData, setLocationData] = React.useState({});
const [paymentData, setPaymentData] = React.useState({}); const [paymentData, setPaymentData] = React.useState({});
const [responeData, setResponeDataData] = React.useState({});

const [transactionData, setTransactionData] = React.useState({}); const [transactionData, setTransactionData] = React.useState({});
const [transactionDate, setTransactionDate] = React.useState(""); const [transactionDate, setTransactionDate] = React.useState("");
const [transactionTime, setTransactionTime] = React.useState(""); const [transactionTime, setTransactionTime] = React.useState("");
@@ -43,13 +46,35 @@ const AckPage = () => {
const [paymentid, setPaymentid] = React.useState(""); const [paymentid, setPaymentid] = React.useState("");


React.useEffect(() => { React.useEffect(() => {
console.log(location.state)
console.log (location.state)
if(Object.keys(location.state).length > 0){ 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(() => { React.useEffect(() => {
console.log(paymentData) console.log(paymentData)
console.log(transactionData) console.log(transactionData)
@@ -58,26 +83,25 @@ const AckPage = () => {
} }
}, [transactionData]); }, [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( // setTransactionData(
// { // {
// "amount": 999.99, // "amount": 999.99,
@@ -99,8 +123,7 @@ const AckPage = () => {
// "transactionid": "20231026170103921" // "transactionid": "20231026170103921"
// } // }
// ) // )
}, [paymentData]);
}


return ( return (
!onReady ? !onReady ?


+ 16
- 6
src/pages/Payment/FPS/FPS.js 查看文件

@@ -37,6 +37,7 @@ const Index = () => {
const [paymentData, setPaymentData] = React.useState({}); const [paymentData, setPaymentData] = React.useState({});
const [onReady, setOnReady] = React.useState(false); const [onReady, setOnReady] = React.useState(false);
const [responeData, setResponeDataData] = React.useState({});
const [fpsTransctionData, setFpsTransctionData] = React.useState({}); const [fpsTransctionData, setFpsTransctionData] = React.useState({});
const [fpsmerchanttimeoutdatetime, setFpsmerchanttimeoutdatetime] = React.useState(""); const [fpsmerchanttimeoutdatetime, setFpsmerchanttimeoutdatetime] = React.useState("");
@@ -76,9 +77,16 @@ const Index = () => {
} }
}, [paymentData]); }, [paymentData]);


React.useEffect(() => {
console.log(responeData)
if(Object.keys(responeData).length > 0 && fpsmerchanttimeoutdatetime!=""){
setFpsTransctionData(responeData)
}
}, [responeData]);

React.useEffect(() => { React.useEffect(() => {
console.log(fpsTransctionData) console.log(fpsTransctionData)
if(Object.keys(fpsTransctionData).length > 0 && fpsmerchanttimeoutdatetime!=""){
if(Object.keys(fpsTransctionData).length > 0 ){
setOnReady(true); setOnReady(true);
currentTimer.current = setInterval(() => { currentTimer.current = setInterval(() => {
setTime((prevTime) => prevTime + 1); setTime((prevTime) => prevTime + 1);
@@ -126,7 +134,7 @@ const Index = () => {
"fpsqrcodeurl": "<fpsqrcodeurl>" "fpsqrcodeurl": "<fpsqrcodeurl>"
} }
*/ */
setFpsTransctionData(responseData)
setResponeDataData(responseData)
const timeoutdatetime = responseData.fpsmerchanttimeoutdatetime const timeoutdatetime = responseData.fpsmerchanttimeoutdatetime
const convertedDateString = timeoutdatetime.replace("[UTC]", ""); const convertedDateString = timeoutdatetime.replace("[UTC]", "");
setFpsmerchanttimeoutdatetime(convertedDateString) setFpsmerchanttimeoutdatetime(convertedDateString)
@@ -143,9 +151,8 @@ const Index = () => {
} }


const getPaymentStatus = () => { const getPaymentStatus = () => {
console.log(fpsTransctionData.paymentstatuscode)
HttpUtils.post({ HttpUtils.post({
url: paymentPath+paymentStatusApi+fpsTransctionData.transactionid,
url: paymentPath+paymentStatusApi+paymentData.transactionid,
params:{ params:{
"apprefid": paymentData.transactionid, "apprefid": paymentData.transactionid,
"webtoken": paymentData.webtoken, "webtoken": paymentData.webtoken,
@@ -155,7 +162,7 @@ const Index = () => {
if (paymentstatuscode != "" && paymentstatuscode != "INPR" ){ if (paymentstatuscode != "" && paymentstatuscode != "INPR" ){
if (paymentstatuscode === 'APPR') { if (paymentstatuscode === 'APPR') {
const timestamp = Date.now(); 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') { } else if (paymentstatuscode === 'CANC') {
// window.top.location.href = paymentPath + payment.config.indexPagePath; // window.top.location.href = paymentPath + payment.config.indexPagePath;
navigate('/payment'); navigate('/payment');
@@ -167,7 +174,7 @@ const Index = () => {
}, },
onError: function(){ onError: function(){
cancelPayment() cancelPayment()
clearInterval(currentTimer.current);
// clearInterval(currentTimer.current);
} }
}); });
}; };
@@ -176,10 +183,13 @@ const Index = () => {
const timeOutDate = new Date(fpsmerchanttimeoutdatetime); const timeOutDate = new Date(fpsmerchanttimeoutdatetime);
const currentTime = new Date; const currentTime = new Date;
console.log(time) console.log(time)
console.log(timeOutDate)
console.log(currentTime)
getPaymentStatus(); getPaymentStatus();
if (timeOutDate.getTime()<currentTime.getTime()){ if (timeOutDate.getTime()<currentTime.getTime()){
console.log("stop"); console.log("stop");
clearInterval(currentTimer.current); clearInterval(currentTimer.current);
cancelPayment()
} }
},[time]) },[time])




+ 2
- 2
src/pages/Payment/index.js 查看文件

@@ -74,8 +74,8 @@ const Index = () => {
useEffect(() => { useEffect(() => {
if (confirmPayment){ if (confirmPayment){
setOpen(false); setOpen(false);
let transactionid = "";
let webtoken = "";
// let transactionid = "";
// let webtoken = "";


if(selectedPaymentMethod === "FPS"){ if(selectedPaymentMethod === "FPS"){
navigate('/payment/fps', {state:{amount:totalAmount,transactionid:transactionData.transactionid,webtoken:transactionData.webtoken} }); navigate('/payment/fps', {state:{amount:totalAmount,transactionid:transactionData.transactionid,webtoken:transactionData.webtoken} });


Loading…
取消
儲存