From 69db0d60b02fc9f1eb918f3c7ea259cabdad7664 Mon Sep 17 00:00:00 2001 From: Alex Cheung Date: Mon, 6 May 2024 18:23:56 +0800 Subject: [PATCH] payment final update --- src/pages/Payment/Details_Public/index.js | 2 + src/pages/Payment/FPS/AckPage.js | 15 ++++-- src/pages/Payment/FPS/FPS.js | 53 ++++++++++++++----- .../ListPanel/PendingPaymentTab.js | 2 +- src/utils/ApiPathConst.js | 2 +- 5 files changed, 55 insertions(+), 19 deletions(-) diff --git a/src/pages/Payment/Details_Public/index.js b/src/pages/Payment/Details_Public/index.js index a611639..68c1cae 100644 --- a/src/pages/Payment/Details_Public/index.js +++ b/src/pages/Payment/Details_Public/index.js @@ -119,6 +119,8 @@ const Index = () => { 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 16c0052..60e2b68 100644 --- a/src/pages/Payment/FPS/AckPage.js +++ b/src/pages/Payment/FPS/AckPage.js @@ -59,12 +59,17 @@ const AckPage = () => { React.useEffect(() => { if (location.state != undefined) { setLocationData(location.state) - loadForm(); } }, []); 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) } @@ -72,7 +77,7 @@ const AckPage = () => { React.useEffect(() => { // console.log(paymentData) - console.log(transactionData) + // console.log(transactionData) if(Object.keys(transactionData).length > 0 ){ setOnReady(true); } @@ -99,9 +104,9 @@ const AckPage = () => { onSuccess: function(responseData){ 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) - responseData.paymentItemList.data["transDateStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "DD/MM/YYYY"); - responseData.paymentItemList.data["transTimeStr"] = DateUtils.dateFormat(responseData.data.transDateTime, "HH:mm:ss"); setItemList(responseData.paymentItemList) setPaymentData(responseData.data); diff --git a/src/pages/Payment/FPS/FPS.js b/src/pages/Payment/FPS/FPS.js index ee79184..c77ceb2 100644 --- a/src/pages/Payment/FPS/FPS.js +++ b/src/pages/Payment/FPS/FPS.js @@ -115,12 +115,7 @@ const Index = () => { }, [fpsTransctionData]); - const loadForm = () => () =>{ - // const timeoutdatetime = "2023-10-26T09:04:30Z[UTC]" - // const convertedDateString = timeoutdatetime.replace("[UTC]", ""); - // setFpsmerchanttimeoutdatetime(convertedDateString) - // setPaymentid("C202310268000681") - // setPaymentstatuscode("APPR") + const loadForm = () => { const webtoken = paymentData.webtoken; const transactionid = paymentData.transactionid; console.log(webtoken) @@ -130,7 +125,6 @@ const Index = () => { localStorage.setItem("transactionid", transactionid) localStorage.setItem("webtoken", webtoken) - HttpUtils.post({ url: UrlUtils.LOAD_PAYMENT_FPS_URL, params:{ @@ -192,16 +186,48 @@ const Index = () => { 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: UrlUtils.PAYMENT_STATUS_API+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; @@ -241,7 +267,7 @@ const Index = () => { // console.log(timeOutDate.getTime()-currentTime.getTime()) getPaymentStatus(); if (timeOutDate.getTime() { "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/PublicNotice/ListPanel/PendingPaymentTab.js b/src/pages/PublicNotice/ListPanel/PendingPaymentTab.js index 510d4ab..20f5306 100644 --- a/src/pages/PublicNotice/ListPanel/PendingPaymentTab.js +++ b/src/pages/PublicNotice/ListPanel/PendingPaymentTab.js @@ -131,7 +131,7 @@ export default function SubmittedTab({ rows }) { const latestData = {}; responseData.forEach(item => { - console.log(item) + // console.log(item) const { appId, timeDiff } = item; if (latestData[appId] === undefined || timeDiff < latestData[appId].timeDiff) { latestData[appId] = item; diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index aee9b69..dcda566 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -155,7 +155,7 @@ export const PAYMENT_AVAILABLE_PAYMENT = apiPath+'/payment/api/availability';//P // 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 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