возможность помнить кудав вернуться в квизе
This commit is contained in:
parent
0948e41294
commit
f0f49a3bc0
@ -16,15 +16,25 @@ interface PaymentBody {
|
||||
|
||||
export const sendPayment = async ({
|
||||
userId,
|
||||
wayback,
|
||||
body,
|
||||
fromSquiz,
|
||||
paymentPurpose,
|
||||
}: {
|
||||
userId: string;
|
||||
wayback: string;
|
||||
body: PaymentBody;
|
||||
fromSquiz: boolean;
|
||||
paymentPurpose: "paycart" | "replenishwallet";
|
||||
}): Promise<[SendPaymentResponse | null, string?]> => {
|
||||
|
||||
|
||||
let returnUrl= `https://${isStaging}hub.pena.digital/afterpay?from=${
|
||||
fromSquiz ? "quiz" : "hub"
|
||||
}&purpose=${paymentPurpose}&userid=${userId}`
|
||||
|
||||
if (wayback) returnUrl += `&wayback=${wayback}`
|
||||
|
||||
const reqeustBody = {
|
||||
currency: "RUB",
|
||||
bankCard: {
|
||||
@ -36,9 +46,7 @@ export const sendPayment = async ({
|
||||
},
|
||||
phoneNumber: "79000000000",
|
||||
login: "login_test",
|
||||
returnUrl: `https://${isStaging}hub.pena.digital/afterpay?from=${
|
||||
fromSquiz ? "quiz" : "hub"
|
||||
}&purpose=${paymentPurpose}&userid=${userId}`,
|
||||
returnUrl,
|
||||
...body,
|
||||
};
|
||||
|
||||
|
@ -20,6 +20,7 @@ export default () => {
|
||||
const userId = useUserStore((state) => state.user?._id);
|
||||
const [searchParams] = useSearchParams();
|
||||
const paymentUserId = searchParams.get("userid");
|
||||
const wayback = searchParams.get("wayback");
|
||||
|
||||
useEffect(() => {
|
||||
const from = searchParams.get("from") || "hub";
|
||||
@ -70,9 +71,10 @@ export default () => {
|
||||
const domain = (host.includes("s") ? "s" : "") + from;
|
||||
const pathname = from === "hub" ? "/tariffs" : "/list";
|
||||
|
||||
setRedirectUrl(
|
||||
`https://${domain}.pena.digital${pathname}?afterpay=${true}&userid=${userId}`
|
||||
);
|
||||
let redirect = `https://${domain}.pena.digital${pathname}?afterpay=${true}&userid=${userId}`
|
||||
if (wayback) redirect += `&wayback=${wayback}`
|
||||
|
||||
setRedirectUrl(redirect);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
@ -133,3 +135,5 @@ export default () => {
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
//https://shub.pena.digital/quizpayment?action=squizpay&dif=50000&data=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY4NDZlODc4hLWF1d__aACP1IpA&userid=6846e878c149e4d24ebf50f3&from=AI&wayback=ai_27964
|
@ -65,14 +65,18 @@ export default function Payment() {
|
||||
const [sorryModalOpen, setSorryModalOpen] = useState<boolean>(false);
|
||||
const [paymentValueField, setPaymentValueField] = useState<string>("0");
|
||||
const [paymentLink, setPaymentLink] = useState<string>("");
|
||||
const [fromSquiz, setIsFromSquiz] = useState<boolean>(false);
|
||||
const location = useLocation();
|
||||
const verificationStatus = useUserStore((state) => state.verificationStatus);
|
||||
const userId = useUserStore((state) => state.userId);
|
||||
const navigate = useNavigate();
|
||||
const handleCustomBackNavigation = useHistoryTracker();
|
||||
|
||||
const {diffMoney, setNewDiff} = useDiffMoney()
|
||||
|
||||
const [fromSquiz, setIsFromSquiz] = useState<boolean>(false);
|
||||
const [waybackToSomeSite, setWaybackToSomeSite] = useState<string>("");
|
||||
|
||||
|
||||
const { diffMoney, setNewDiff } = useDiffMoney()
|
||||
|
||||
const notEnoughMoneyAmount =
|
||||
(location.state?.notEnoughMoneyAmount as number) ?? 0;
|
||||
@ -83,8 +87,8 @@ export default function Payment() {
|
||||
|
||||
useEffect(() => {
|
||||
if (diffMoney > 0) {
|
||||
setNewDiff(0)
|
||||
setPaymentValueField((diffMoney / 100).toString())
|
||||
setNewDiff(0);
|
||||
setPaymentValueField((diffMoney / 100).toString());
|
||||
}
|
||||
}, [diffMoney])
|
||||
|
||||
@ -96,10 +100,14 @@ export default function Payment() {
|
||||
setIsFromSquiz(true);
|
||||
setPaymentValueField((Number(params.get("dif") || "0") / 100).toString());
|
||||
}
|
||||
|
||||
const wayback = params.get("wayback");
|
||||
if (wayback) setWaybackToSomeSite(wayback);
|
||||
|
||||
navigate(`/payment`, {
|
||||
replace: true,
|
||||
});
|
||||
}, [ ]);
|
||||
}, []);
|
||||
|
||||
async function handleChoosePaymentClick() {
|
||||
if (!selectedPaymentMethod) {
|
||||
@ -116,6 +124,7 @@ export default function Payment() {
|
||||
const [sendPaymentResponse, sendPaymentError] = await sendPayment({
|
||||
userId: userId ?? "",
|
||||
fromSquiz,
|
||||
wayback,
|
||||
body: {
|
||||
type: selectedPaymentMethod,
|
||||
amount: Number(
|
||||
|
Loading…
Reference in New Issue
Block a user