diff --git a/src/api/wallet.ts b/src/api/wallet.ts index 9017930..f3d812f 100644 --- a/src/api/wallet.ts +++ b/src/api/wallet.ts @@ -2,32 +2,25 @@ import { makeRequest } from "@frontend/kitui"; import { SendPaymentRequest, SendPaymentResponse } from "@root/model/wallet"; import { parseAxiosError } from "@root/utils/parse-error"; +const isStaging = (() => { + const host = window.location.hostname; + return host.includes("s") ? "s" : ""; +})(); + const apiUrl = process.env.REACT_APP_DOMAIN + "/customer"; -const testPaymentBody: SendPaymentRequest = { - type: "bankCard", - amount: 15020, - currency: "RUB", - bankCard: { - number: "RUB", - expiryYear: "2021", - expiryMonth: "05", - csc: "05", - cardholder: "IVAN IVANOV", - }, - phoneNumber: "79000000000", - login: "login_test", - returnUrl: window.location.origin + "/wallet", -}; +interface PaymentBody { + type: string; + amount: number; +} export async function sendPayment({ - body = testPaymentBody, - fromSquiz = false, + body, + fromSquiz }: { - body?: SendPaymentRequest; + body: PaymentBody; fromSquiz: boolean; }): Promise<[SendPaymentResponse | null, string?]> { - if (fromSquiz) body.returnUrl = "squiz.pena.digital/list?action=fromhub"; try { const sendPaymentResponse = await makeRequest< SendPaymentRequest, @@ -38,7 +31,20 @@ export async function sendPayment({ method: "POST", useToken: true, withCredentials: false, - body, + body: { + currency: "RUB", + bankCard: { + number: "RUB", + expiryYear: "2021", + expiryMonth: "05", + csc: "05", + cardholder: "IVAN IVANOV", + }, + phoneNumber: "79000000000", + login: "login_test", + returnUrl: `https://${isStaging}hub.pena.digital/afterpay?from=${fromSquiz ? "quiz" : "hub"}`, + ...body + } }); return [sendPaymentResponse]; @@ -55,7 +61,7 @@ export const sendRSPayment = async (money: number): Promise => { url: apiUrl + "/wallet/rspay", method: "POST", useToken: true, - body: {money: money}, + body: { money: money }, withCredentials: false, }); diff --git a/src/assets/Icons/ColorWallet.svg b/src/assets/Icons/ColorWallet.svg new file mode 100644 index 0000000..f19fe45 --- /dev/null +++ b/src/assets/Icons/ColorWallet.svg @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/index.tsx b/src/index.tsx index 21a1420..026dbcf 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -35,6 +35,7 @@ import PrivacyPolicy from "@root/docs/content/PrivacyPolicy" import RecoverPassword from "@root/pages/auth/RecoverPassword" import OutdatedLink from "@root/pages/auth/OutdatedLink" import { verify } from "./pages/AccountSettings/helper" +import AfterPay from "./pages/AfterPay" pdfjs.GlobalWorkerOptions.workerSrc = new URL("pdfjs-dist/build/pdf.worker.min.js", import.meta.url).toString() @@ -98,7 +99,7 @@ const App = () => { } /> } /> } /> - + } /> }> }> @@ -117,12 +118,13 @@ const App = () => { } /> - }/> - } /> + } /> + } /> }> - }/> - }/> + } /> + } /> + } /> ) diff --git a/src/pages/AfterPay/index.tsx b/src/pages/AfterPay/index.tsx new file mode 100644 index 0000000..e196ec8 --- /dev/null +++ b/src/pages/AfterPay/index.tsx @@ -0,0 +1,70 @@ +import { Box, Button, Typography, useTheme, useMediaQuery } from "@mui/material" +import wallet_icon from "@root/assets/Icons/ColorWallet.svg" +import { Link } from "react-router-dom"; +//Привет :) +const { domain, pathname } = (() => { + const params = new URLSearchParams(window.location.search); + const from = params.get("from") || "hub"; + if (window.location.pathname.includes("afterpay")) history.pushState(null, document.title, "/afterpay"); + const host = window.location.hostname; + return { + domain: (host.includes("s") ? "s" : "") + from, + pathname: from === "hub" ? "/wallet" : "" + } +})(); + +export default () => { + const theme = useTheme(); + const phone = useMediaQuery(theme.breakpoints.down(375)); + + return ( + + + + Спасибо за оплату! + Ваш платеж принят и в течение 10 минут товары будут зачислены + + + + ) +} \ No newline at end of file diff --git a/src/pages/Payment/Payment.tsx b/src/pages/Payment/Payment.tsx index 3ca0f6f..1c26153 100644 --- a/src/pages/Payment/Payment.tsx +++ b/src/pages/Payment/Payment.tsx @@ -22,7 +22,7 @@ import { sendPayment, sendRSPayment } from "@root/api/wallet"; import { getMessageFromFetchError } from "@frontend/kitui"; import { enqueueSnackbar } from "notistack"; import { currencyFormatter } from "@root/utils/currencyFormatter"; -import { useLocation, useNavigate } from "react-router-dom"; +import { Link, useLocation, useNavigate } from "react-router-dom"; import { useHistoryTracker } from "@root/utils/hooks/useHistoryTracker"; import { useUserStore } from "@root/stores/user"; import { VerificationStatus } from "@root/model/account"; @@ -62,6 +62,7 @@ export default function Payment() { const location = useLocation(); const verificationStatus = useUserStore((state) => state.verificationStatus); const navigate = useNavigate(); + const handleCustomBackNavigation = useHistoryTracker(); const notEnoughMoneyAmount = (location.state?.notEnoughMoneyAmount as number) ?? 0; @@ -86,6 +87,7 @@ export default function Payment() { async function handleChoosePaymentClick() { if (!selectedPaymentMethod) { + enqueueSnackbar("Введите метод оплаты") return; } @@ -100,17 +102,6 @@ export default function Payment() { body: { type: selectedPaymentMethod, amount: Number(paymentValueField) * 100, - currency: "RUB", - bankCard: { - number: "RUB", - expiryYear: "2021", - expiryMonth: "05", - csc: "05", - cardholder: "IVAN IVANOV", - }, - phoneNumber: "79000000000", - login: "login_test", - returnUrl: window.location.origin + "/wallet", }, }); @@ -178,7 +169,6 @@ export default function Payment() { } - const handleCustomBackNavigation = useHistoryTracker(); return ( (false); + + useEffect(() => { + const host = window.location.hostname; + let isTest = host.includes("s"); + setIsTestServer(isTest); + }, []); + + return { isTestServer }; +}