diff --git a/lib/api/paymentCheckout.ts b/lib/api/paymentCheckout.ts index bae7f1de..efd5171f 100644 --- a/lib/api/paymentCheckout.ts +++ b/lib/api/paymentCheckout.ts @@ -16,8 +16,11 @@ export default async function paymentCheckout( const isExistingCustomer = listByEmail?.data[0]?.id || undefined; + console.log("isExistingCustomer", listByEmail?.data[0]); + const NEXT_PUBLIC_TRIAL_PERIOD_DAYS = - process.env.NEXT_PUBLIC_TRIAL_PERIOD_DAYS; + Number(process.env.NEXT_PUBLIC_TRIAL_PERIOD_DAYS) || 14; + const session = await stripe.checkout.sessions.create({ customer: isExistingCustomer ? isExistingCustomer : undefined, line_items: [ @@ -34,9 +37,9 @@ export default async function paymentCheckout( enabled: true, }, subscription_data: { - trial_period_days: NEXT_PUBLIC_TRIAL_PERIOD_DAYS - ? Number(NEXT_PUBLIC_TRIAL_PERIOD_DAYS) - : 14, + trial_period_days: isExistingCustomer + ? undefined + : NEXT_PUBLIC_TRIAL_PERIOD_DAYS, }, }); diff --git a/pages/subscribe.tsx b/pages/subscribe.tsx index 3663f244..a6b96ee9 100644 --- a/pages/subscribe.tsx +++ b/pages/subscribe.tsx @@ -5,6 +5,7 @@ import { useRouter } from "next/router"; import CenteredForm from "@/layouts/CenteredForm"; import { Plan } from "@/types/global"; import AccentSubmitButton from "@/components/AccentSubmitButton"; +import useAccountStore from "@/store/account"; export default function Subscribe() { const [submitLoader, setSubmitLoader] = useState(false); @@ -12,6 +13,8 @@ export default function Subscribe() { const [plan, setPlan] = useState(1); + const { account } = useAccountStore(); + const router = useRouter(); async function submit() { @@ -37,7 +40,6 @@ export default function Subscribe() {

-

You will be redirected to Stripe, feel free to reach out to us at{" "} @@ -47,7 +49,6 @@ export default function Subscribe() { in case of any issue.

-
-

${plan === Plan.monthly ? "4" : "3"} @@ -89,13 +89,14 @@ export default function Subscribe() {

- {process.env.NEXT_PUBLIC_TRIAL_PERIOD_DAYS}-day free trial, then $ - {plan === Plan.monthly ? "4 per month" : "36 annually"} + {account.username + ? "" + : `${process.env.NEXT_PUBLIC_TRIAL_PERIOD_DAYS}-day free trial, then `} + ${plan === Plan.monthly ? "4 per month" : "36 annually"}

+ VAT if applicable

- -
signOut()} className="w-fit mx-auto cursor-pointer text-neutral font-semibold "