From 02ee84791ff8ed52750d1a8d315b7de99249d8e0 Mon Sep 17 00:00:00 2001 From: Alex Cheung Date: Wed, 24 Apr 2024 17:55:17 +0800 Subject: [PATCH] fix payment --- .../Payment/Details_Public/PaymentDetails.js | 6 ++-- src/pages/Payment/Details_Public/index.js | 17 +++++------ src/pages/Payment/FPS/fpscallback.js | 29 ++++++------------- src/pages/Payment/PaymentCallback.js | 17 ++++++----- 4 files changed, 31 insertions(+), 38 deletions(-) diff --git a/src/pages/Payment/Details_Public/PaymentDetails.js b/src/pages/Payment/Details_Public/PaymentDetails.js index ebeebc5..219d537 100644 --- a/src/pages/Payment/Details_Public/PaymentDetails.js +++ b/src/pages/Payment/Details_Public/PaymentDetails.js @@ -24,12 +24,14 @@ 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]); diff --git a/src/pages/Payment/Details_Public/index.js b/src/pages/Payment/Details_Public/index.js index f425fd9..a611639 100644 --- a/src/pages/Payment/Details_Public/index.js +++ b/src/pages/Payment/Details_Public/index.js @@ -59,6 +59,9 @@ const Index = () => { React.useEffect(() => { if (Object.keys(transactionData).length > 0) { + console.log(transactionData) + console.log(itemList) + console.log(record) setOnReady(true); } }, [transactionData]); @@ -99,27 +102,23 @@ const Index = () => { "paymentId": params.id }, onSuccess: function(responseData2){ - responseData2.paymentItemList.data["transDateStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "DD/MM/YYYY"); - responseData2.paymentItemList.data["transTimeStr"] = DateUtils.dateFormat(responseData2.data.transDateTime, "HH:mm:ss"); + 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); - setResponeData(responseData2.paymentItemList) }, onError: function(){ 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); - setResponeData(responseData.paymentItemList) + 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"); - setItemList(responseData.paymentItemList) - setRecord(responseData.data); - setResponeData(responseData.paymentItemList) + setResponeData(responseData) } } }); 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/PaymentCallback.js b/src/pages/Payment/PaymentCallback.js index 996f394..443a3d7 100644 --- a/src/pages/Payment/PaymentCallback.js +++ b/src/pages/Payment/PaymentCallback.js @@ -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]); @@ -117,14 +119,15 @@ const Index = () => { "transactionid":Number(transactionid) }, onSuccess: function (responseData) { - localStorage.removeItem("webtoken"); - localStorage.removeItem("transactionid"); + if (responseData.paymentdetail?.result?.paymentstatuscode === "APPR") { + 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); - // if (responseData.paymentdetail?.result?.paymentstatuscode === "APPR") { // }