Sign up stripe redirect
parent
72cc95a0d7
commit
da7e599910
|
@ -7,6 +7,7 @@ import type { SubmitHandler } from "react-hook-form";
|
|||
import { FormProvider, useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
|
||||
import getStripe from "@calcom/app-store/stripepayment/lib/client";
|
||||
import { checkPremiumUsername } from "@calcom/features/ee/common/lib/checkPremiumUsername";
|
||||
import { getOrgFullDomain } from "@calcom/features/ee/organizations/lib/orgDomains";
|
||||
import { isSAMLLoginEnabled } from "@calcom/features/ee/sso/lib/saml";
|
||||
|
@ -52,8 +53,18 @@ export default function Signup({ prepopulateFormValues, token, orgSlug }: Signup
|
|||
const handleErrors = async (resp: Response) => {
|
||||
if (!resp.ok) {
|
||||
const err = await resp.json();
|
||||
if (err.checkoutSessionId) {
|
||||
const stripe = await getStripe();
|
||||
if (stripe) {
|
||||
const { error } = await stripe.redirectToCheckout({
|
||||
sessionId: err.checkoutSessionId,
|
||||
});
|
||||
console.warn(error.message);
|
||||
}
|
||||
} else {
|
||||
throw new Error(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const signUp: SubmitHandler<FormValues> = async (data) => {
|
||||
|
|
|
@ -33,11 +33,12 @@ export const SENDER_NAME = process.env.NEXT_PUBLIC_SENDGRID_SENDER_NAME || "Cal.
|
|||
export const CAL_URL = new URL(WEBAPP_URL).hostname.endsWith(".vercel.app") ? WEBAPP_URL : WEBSITE_URL;
|
||||
|
||||
export const IS_CALCOM =
|
||||
WEBAPP_URL &&
|
||||
true ||
|
||||
(WEBAPP_URL &&
|
||||
(new URL(WEBAPP_URL).hostname.endsWith("cal.com") ||
|
||||
new URL(WEBAPP_URL).hostname.endsWith("cal.dev") ||
|
||||
new URL(WEBAPP_URL).hostname.endsWith("cal.qa") ||
|
||||
new URL(WEBAPP_URL).hostname.endsWith("cal-staging.com"));
|
||||
new URL(WEBAPP_URL).hostname.endsWith("cal-staging.com")));
|
||||
|
||||
export const CONSOLE_URL =
|
||||
new URL(WEBAPP_URL).hostname.endsWith(".cal.dev") ||
|
||||
|
|
Loading…
Reference in New Issue