Browse Source

fix new password with forgot password and add fps prefix for fpsqrcodeurl

master
Alex Cheung 1 year ago
parent
commit
b71885d1de
3 changed files with 51 additions and 40 deletions
  1. +33
    -6
      src/pages/Payment/FPS/FPS.js
  2. +17
    -33
      src/pages/authentication/ForgotPassword/AuthCallback/index.js
  3. +1
    -1
      src/utils/ApiPathConst.js

+ 33
- 6
src/pages/Payment/FPS/FPS.js View File

@@ -46,6 +46,7 @@ const Index = () => {
const [paymentId, setPaymentId] = React.useState("");
const [fpsqrcodeurl, setFpsqrcodeurl] = React.useState("");
const [fpsqrcodeurlPrd, setFpsqrcodeurlPrd] = React.useState("");
const [fpsqrcodeurlFps, setFpsqrcodeurlFps] = React.useState("");
const [browserType, setBrowserType] = React.useState("");
const mobileBrowser = "Mobile";
const desktopBrowser = "Desktop";
@@ -119,16 +120,21 @@ const Index = () => {
// setFpsmerchanttimeoutdatetime(convertedDateString)
// setPaymentid("C202310268000681")
// setPaymentstatuscode("APPR")
const webtoken = paymentData.webtoken;
const transactionid = paymentData.transactionid;
console.log(webtoken)
console.log(transactionid)
localStorage.removeItem("transactionid")
localStorage.removeItem("webtoken")
localStorage.setItem("transactionid", paymentData.transactionid)
localStorage.setItem("webtoken", paymentData.webtoken)
localStorage.setItem("transactionid", transactionid)
localStorage.setItem("webtoken", webtoken)


HttpUtils.post({
url: paymentPath+loadPaymentUrl,
params:{
"transactionid": paymentData.transactionid,
"webtoken": paymentData.webtoken,
"transactionid": transactionid,
"webtoken": webtoken,
"paymentmethod":"04,BCFP,FPS",
"order": {
"totalamount":paymentData.amount,
@@ -169,13 +175,20 @@ const Index = () => {
const parsedUrl = new URL(responseData.fpsqrcodeurl);
const fpsqrcodeurl = "https://"+window.location.hostname+'/payment'+parsedUrl.pathname;
const fpsqrcodeurlwithFps = "https://"+"fps."+window.location.hostname+'/payment'+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='+paymentData.transactionid+"&WEB_TOKEN="+paymentData.webtoken+"&PAYMENT_ID="+localStorage.getItem("paymentId"));
+ 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='+paymentData.transactionid+"&WEB_TOKEN="+paymentData.webtoken+"&PAYMENT_ID="+localStorage.getItem("paymentId"));
+ 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)

}
});
@@ -254,6 +267,10 @@ const Index = () => {
window.location.assign(fpsqrcodeurlPrd);
}

const mobliePaymentFps = ()=>{
window.location.assign(fpsqrcodeurlFps);
}

return (
!onReady ?
<Grid container sx={{ minHeight: '95vh', mb: 3 }} direction="column" justifyContent="center" alignItems="center">
@@ -308,6 +325,16 @@ const Index = () => {
}}
sx={{ m: 4 }}
>請選擇支付程式付款-PRD</Button>
<Button
component="span"
variant="contained"
size="large"
color="primary"
onClick={()=>{
mobliePaymentFps();
}}
sx={{ m: 4 }}
>請選擇支付程式付款-fps prefix</Button>
</Typography>
:
<Typography variant="h3" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "center" }}>


+ 17
- 33
src/pages/authentication/ForgotPassword/AuthCallback/index.js View File

@@ -35,6 +35,8 @@ import { EyeInvisibleOutlined, EyeOutlined } from '@ant-design/icons';
import axios from 'axios';
import { useParams,Link } from 'react-router-dom';
import CancelOutlinedIcon from '@mui/icons-material/CancelOutlined';
import LocaleContext from "components/I18nProvider";

// ==============================|| DASHBOARD - DEFAULT ||============================== //

const Index = () => {
@@ -46,11 +48,13 @@ const Index = () => {
const [verifyState, setVerifyState] = React.useState(null)
const [enterUseEffect, setEnterUseEffect] = React.useState(false)
const [username, setUsername] = React.useState("")
const { setLocale } = React.useContext(LocaleContext);
const params = useParams()
const intl = useIntl();
React.useEffect(() => {
console.log(params);
setEnterUseEffect(true)
}, []);

@@ -75,13 +79,13 @@ const Index = () => {
setUsername(response.data.username)
setVerifyState(true)
} else {
setVerifyState(true)
setVerifyState(false)
}
setLoding(false)
}
).catch(error => {
console.log(error)
setVerifyState(true)
setVerifyState(false)
setLoding(false)
});

@@ -90,16 +94,14 @@ const Index = () => {

const goLogin = async (values) =>{
dispatch(handleLogoutFunction());
console.log(username)
await axios.patch(UrlUtils.PATCH_FORGOT_PASSWORD_NEW_PASSWORD, {
params: {
HttpUtils.post({
url: UrlUtils.POST_FORGOT_PASSWORD_NEW_PASSWORD,
params:{
username: username,
newPassword: values.password
}
}).then(
(response)=>{
if (response.status === 204) {
useJwt
},
onSuccess: () => {
useJwt
.login({ username: username, password: values.password })
.then((response) => {
// console.log(response)
@@ -139,28 +141,10 @@ const Index = () => {
.catch((error) => {
// setSuccess(false)
console.error(error)
console.error(error.response.data.error)
setErrorMassage(error.response.data.error)
setOpen(true)
// console.error(error.response.data.error)
// setErrorMassage(error.response.data.error)
// setOpen(true)
});
} else {
setVerifyState(true)
}
setLoding(false)
}
).catch(error => {
console.log(error)
setVerifyState(true)
setLoding(false)
});
HttpUtils.patch({
url: UrlUtils.PATCH_FORGOT_PASSWORD_NEW_PASSWORD,
params:{
username: username,
newPassword: values.password
},
onSuccess: () => {
},
onFail: (response)=>{
console.log("Fail");
@@ -336,7 +320,7 @@ const Index = () => {
name="username"
label={intl.formatMessage({id: 'userLoginName'}) + ":"}
placeholder={intl.formatMessage({id: 'userLoginName'})}
defaultValue={username}
// defaultValue={username}
value={username}
disabled={true} />
</Grid>
@@ -420,7 +404,7 @@ const Index = () => {
name="confirmPassword"
label={intl.formatMessage({id: 'confirmPassword'}) + ":"}
placeholder={intl.formatMessage({id: 'confirmPassword'})}
defaultValue={formik.values.confirmPassword.trim()}
// defaultValue={formik.values.confirmPassword.trim()}
value={formik.values.confirmPassword.trim()}
error={Boolean(formik.touched.confirmPassword && formik.errors.confirmPassword)}
onBlur={formik.handleBlur}


+ 1
- 1
src/utils/ApiPathConst.js View File

@@ -74,7 +74,7 @@ export const GET_USER_EMAIL = apiPath+'/user/email';
export const GET_ID = apiPath+'/user/verifyID';
export const GET_VERIFY_USER_ACCOUNT = apiPath+'/user/verifyEmail';
export const GET_FORGOT_PASSWORD_VERIFY_USER_ACCOUNT = apiPath+'/user/verifyForgotPasswordEmail';
export const PATCH_FORGOT_PASSWORD_NEW_PASSWORD = apiPath+'/user/forgotPassword/newPassword';
export const POST_FORGOT_PASSWORD_NEW_PASSWORD = apiPath+'/user/forgotPasswordNewPassword';


//Public


Loading…
Cancel
Save