38 lines
986 B
JavaScript
38 lines
986 B
JavaScript
import { useParams } from "react-router-dom";
|
|
import { useEffect } from "react";
|
|
import { myFetch, showUnkownErrorNotification } from "../../utils";
|
|
import MyCenteredSpin from "../../Components/MyCenteredSpin";
|
|
|
|
export default function CheckoutSuccess() {
|
|
const { sessionId } = useParams();
|
|
|
|
useEffect(() => {
|
|
setInterval(() => {
|
|
myFetch({
|
|
method: "POST",
|
|
url: "/payment/checkout/success",
|
|
body: {
|
|
sessionId: sessionId,
|
|
},
|
|
})
|
|
.then((response) => {
|
|
// payment success
|
|
if (response.status === 1) {
|
|
const session = localStorage.getItem("tmp_session");
|
|
|
|
if (session) {
|
|
localStorage.setItem("session", session);
|
|
}
|
|
|
|
localStorage.removeItem("tmp_session");
|
|
|
|
window.location.href = "/";
|
|
}
|
|
})
|
|
.catch(() => showUnkownErrorNotification());
|
|
}, 2000);
|
|
}, []);
|
|
|
|
return <MyCenteredSpin fullHeight />;
|
|
}
|