feat: afterpay userid checking

This commit is contained in:
IlyaDoronin 2024-04-08 12:37:42 +03:00
parent f188bcee2d
commit 31f103c3ab

@ -1,5 +1,6 @@
import { useNavigate } from "react-router-dom";
import { useWallet, setCash } from "@root/cash";
import { setCash } from "@root/cash";
import { useUserStore } from "@root/user";
import { payCart } from "@api/cart";
import { currencyFormatter } from "../../pages/Tariffs/tariffsUtils/currencyFormatter";
@ -7,6 +8,7 @@ import { currencyFormatter } from "../../pages/Tariffs/tariffsUtils/currencyForm
const MINUTE = 1000 * 60;
export const useAfterpay = () => {
const userId = useUserStore((state) => state.userId);
const navigate = useNavigate();
// const { cash } = useWallet()
@ -46,12 +48,13 @@ export const useAfterpay = () => {
setTimeout(tryPayCart, tryCount > 10 ? MINUTE / 60 : MINUTE / 6);
}
};
const checkParams = () => {
const afterpay = new URLSearchParams(window.location.search).get(
"afterpay",
);
if (afterpay) {
const checkParams = () => {
const params = new URLSearchParams(window.location.search);
const afterpay = params.get("afterpay");
const paymentUserId = params.get("userid");
if (afterpay && userId === paymentUserId) {
checkPayment();
}
};