|
|
@@ -59,6 +59,7 @@ const Index = () => { |
|
|
const [fpsqrcodeurlFps, setFpsqrcodeurlFps] = React.useState(""); |
|
|
const [fpsqrcodeurlFps, setFpsqrcodeurlFps] = React.useState(""); |
|
|
const [browserType, setBrowserType] = React.useState(""); |
|
|
const [browserType, setBrowserType] = React.useState(""); |
|
|
const [sysEnv, setSysEnv] = React.useState(""); |
|
|
const [sysEnv, setSysEnv] = React.useState(""); |
|
|
|
|
|
const [isError, setIsError] = React.useState(false); |
|
|
const mobileBrowser = "Mobile"; |
|
|
const mobileBrowser = "Mobile"; |
|
|
const desktopBrowser = "Desktop"; |
|
|
const desktopBrowser = "Desktop"; |
|
|
|
|
|
|
|
|
@@ -171,49 +172,68 @@ const Index = () => { |
|
|
// "eserviceid":"<eserviceid>" |
|
|
// "eserviceid":"<eserviceid>" |
|
|
}, |
|
|
}, |
|
|
onSuccess: function(responseData){ |
|
|
onSuccess: function(responseData){ |
|
|
/* |
|
|
|
|
|
{ |
|
|
|
|
|
"paymentid": "<paymentid>", |
|
|
|
|
|
"paymentstatus": "<paymentstatus>", |
|
|
|
|
|
"fpsmerchanttimeoutdatetime": <fpsmerchanttimeoutdatetime>, |
|
|
|
|
|
"fpsqrcodeimgbase64": "<fpsqrcodeimgbase64>", |
|
|
|
|
|
"fpsqrcodeurl": "<fpsqrcodeurl>" |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
/* |
|
|
|
|
|
{ |
|
|
|
|
|
"paymentid": "<paymentid>", |
|
|
|
|
|
"paymentstatus": "<paymentstatus>", |
|
|
|
|
|
"fpsmerchanttimeoutdatetime": <fpsmerchanttimeoutdatetime>, |
|
|
|
|
|
"fpsqrcodeimgbase64": "<fpsqrcodeimgbase64>", |
|
|
|
|
|
"fpsqrcodeurl": "<fpsqrcodeurl>" |
|
|
|
|
|
} |
|
|
|
|
|
*/ |
|
|
|
|
|
if (!responseData || !responseData.fpsqrcodeurl) { |
|
|
|
|
|
throw new Error("Missing expected response data"); |
|
|
|
|
|
} |
|
|
|
|
|
setResponeDataData(responseData) |
|
|
|
|
|
const timeoutdatetime = responseData.fpsmerchanttimeoutdatetime |
|
|
|
|
|
setSysEnv(responseData.sysEnv) |
|
|
|
|
|
const searchString = "[UTC]"; |
|
|
|
|
|
let convertedDateString = ""; |
|
|
|
|
|
if ( timeoutdatetime.toString().includes(searchString) ){ |
|
|
|
|
|
convertedDateString = timeoutdatetime.replace("[UTC]", ""); |
|
|
|
|
|
} else { |
|
|
|
|
|
convertedDateString = timeoutdatetime; |
|
|
} |
|
|
} |
|
|
*/ |
|
|
|
|
|
setResponeDataData(responseData) |
|
|
|
|
|
const timeoutdatetime = responseData.fpsmerchanttimeoutdatetime |
|
|
|
|
|
setSysEnv(responseData.sysEnv) |
|
|
|
|
|
const searchString = "[UTC]"; |
|
|
|
|
|
let convertedDateString = ""; |
|
|
|
|
|
if ( timeoutdatetime.toString().includes(searchString) ){ |
|
|
|
|
|
convertedDateString = timeoutdatetime.replace("[UTC]", ""); |
|
|
|
|
|
} else { |
|
|
|
|
|
convertedDateString = timeoutdatetime; |
|
|
|
|
|
|
|
|
setFpsmerchanttimeoutdatetime(convertedDateString) |
|
|
|
|
|
|
|
|
|
|
|
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(fpsqrcodeurlwithFps) + '&callback=' |
|
|
|
|
|
+ encodeURIComponent("https://"+window.location.hostname+ '/paymentPage/fps/fpscallback?&PAYMENT_ID='+localStorage.getItem("paymentId")); |
|
|
|
|
|
const openPASGUrlPrd = pasgPathPrd + '?pay_req_obj=' + encodeURIComponent(fpsqrcodeurlwithFps) + '&callback=' |
|
|
|
|
|
+ encodeURIComponent("https://"+window.location.hostname+ '/paymentPage/fps/fpscallback?&PAYMENT_ID='+localStorage.getItem("paymentId")); |
|
|
|
|
|
const openPASGUrlPrdFps = pasgPath + '?pay_req_obj=' + encodeURIComponent(fpsqrcodeurlwithFps) + '&callback=' |
|
|
|
|
|
+ encodeURIComponent("https://"+window.location.hostname+ '/paymentPage/fps/fpscallback?&PAYMENT_ID='+localStorage.getItem("paymentId")); |
|
|
|
|
|
// const openPASGUrl = 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")); |
|
|
|
|
|
// const openPASGUrlPrd = pasgPathPrd + '?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")); |
|
|
|
|
|
// 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) |
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
console.error("Error processing response:", e); |
|
|
|
|
|
setIsError(true); |
|
|
|
|
|
setOnReady(true); |
|
|
} |
|
|
} |
|
|
setFpsmerchanttimeoutdatetime(convertedDateString) |
|
|
|
|
|
|
|
|
|
|
|
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(fpsqrcodeurlwithFps) + '&callback=' |
|
|
|
|
|
+ encodeURIComponent("https://"+window.location.hostname+ '/paymentPage/fps/fpscallback?&PAYMENT_ID='+localStorage.getItem("paymentId")); |
|
|
|
|
|
const openPASGUrlPrd = pasgPathPrd + '?pay_req_obj=' + encodeURIComponent(fpsqrcodeurlwithFps) + '&callback=' |
|
|
|
|
|
+ encodeURIComponent("https://"+window.location.hostname+ '/paymentPage/fps/fpscallback?&PAYMENT_ID='+localStorage.getItem("paymentId")); |
|
|
|
|
|
const openPASGUrlPrdFps = pasgPath + '?pay_req_obj=' + encodeURIComponent(fpsqrcodeurlwithFps) + '&callback=' |
|
|
|
|
|
+ encodeURIComponent("https://"+window.location.hostname+ '/paymentPage/fps/fpscallback?&PAYMENT_ID='+localStorage.getItem("paymentId")); |
|
|
|
|
|
// const openPASGUrl = 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")); |
|
|
|
|
|
// const openPASGUrlPrd = pasgPathPrd + '?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")); |
|
|
|
|
|
// 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) |
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
onFail: function(error){ |
|
|
|
|
|
console.error("post onFail:", error); |
|
|
|
|
|
setIsError(true); |
|
|
|
|
|
setOnReady(true); |
|
|
|
|
|
}, |
|
|
|
|
|
onError: function(error){ |
|
|
|
|
|
console.error("post onError:", error); |
|
|
|
|
|
setIsError(true); |
|
|
|
|
|
setOnReady(true); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
@@ -313,19 +333,29 @@ const Index = () => { |
|
|
const cancelPayment = ()=>{ |
|
|
const cancelPayment = ()=>{ |
|
|
if (Object.keys(paymentData).length>0){ |
|
|
if (Object.keys(paymentData).length>0){ |
|
|
getPaymentStatus() |
|
|
getPaymentStatus() |
|
|
if (paymentStatusCode === "INPR"){ |
|
|
|
|
|
|
|
|
if (paymentStatusCode === "INPR" || isError || paymentStatusCode === ""){ |
|
|
HttpUtils.post({ |
|
|
HttpUtils.post({ |
|
|
url: UrlUtils.CANCEL_PAYMENT_URL, |
|
|
url: UrlUtils.CANCEL_PAYMENT_URL, |
|
|
params:{ |
|
|
params:{ |
|
|
"transactionid": paymentData.transactionid, |
|
|
"transactionid": paymentData.transactionid, |
|
|
"webtoken": paymentData.webtoken, |
|
|
"webtoken": paymentData.webtoken, |
|
|
"paymentid": fpsTransctionData.paymentid |
|
|
|
|
|
|
|
|
"paymentid": fpsTransctionData.paymentid || localStorage.getItem("paymentId") |
|
|
}, |
|
|
}, |
|
|
onSuccess: function(){ |
|
|
onSuccess: function(){ |
|
|
navigate('/paymentPage/fps/ackpage'); |
|
|
navigate('/paymentPage/fps/ackpage'); |
|
|
let page = '/paymentPage/fps/ackpage'; |
|
|
let page = '/paymentPage/fps/ackpage'; |
|
|
let stateParams = { state: { transactionid: paymentData.transactionid} } |
|
|
let stateParams = { state: { transactionid: paymentData.transactionid} } |
|
|
navigate(page, stateParams); |
|
|
navigate(page, stateParams); |
|
|
|
|
|
}, |
|
|
|
|
|
onFail: function(){ |
|
|
|
|
|
let page = '/paymentPage/fps/ackpage'; |
|
|
|
|
|
let stateParams = { state: { transactionid: paymentData.transactionid} } |
|
|
|
|
|
navigate(page, stateParams); |
|
|
|
|
|
}, |
|
|
|
|
|
onError: function(){ |
|
|
|
|
|
let page = '/paymentPage/fps/ackpage'; |
|
|
|
|
|
let stateParams = { state: { transactionid: paymentData.transactionid} } |
|
|
|
|
|
navigate(page, stateParams); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
@@ -378,7 +408,12 @@ const Index = () => { |
|
|
<br /> |
|
|
<br /> |
|
|
{"HK$ " + currencyFormat(paymentData.amount)} |
|
|
{"HK$ " + currencyFormat(paymentData.amount)} |
|
|
</Typography> |
|
|
</Typography> |
|
|
{browserType==mobileBrowser? |
|
|
|
|
|
|
|
|
{isError ? |
|
|
|
|
|
<Typography variant="h3" color="error" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "center" }}> |
|
|
|
|
|
<FormattedMessage id="fpsPaymentErrorMsg"/> |
|
|
|
|
|
</Typography> |
|
|
|
|
|
: |
|
|
|
|
|
browserType==mobileBrowser? |
|
|
<Typography variant="h3" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "center" }}> |
|
|
<Typography variant="h3" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "center" }}> |
|
|
{ |
|
|
{ |
|
|
sysEnv=="prod"? |
|
|
sysEnv=="prod"? |
|
|
|