diff --git a/src/utils/hooks/useAfterpay.ts b/src/utils/hooks/useAfterpay.ts index 6b07fec2..c7218508 100644 --- a/src/utils/hooks/useAfterpay.ts +++ b/src/utils/hooks/useAfterpay.ts @@ -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(); } };