diff --git a/.gitignore b/.gitignore index a8e3e84..7419555 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ htmlcov/ # Environment files .env* +!.env.production !.env.example .turbo diff --git a/apps/api/.env.production b/apps/api/.env.production new file mode 100644 index 0000000..b9de357 --- /dev/null +++ b/apps/api/.env.production @@ -0,0 +1,12 @@ +SUPABASE_URL=https://mhcafqvzbrrwvahpvvzd.supabase.co + +STREAM_CHAT_API_KEY=h7bwnn8ynjpx + +XTABLO_URL=https://app.xtablo.com + +R2_ACCOUNT_ID="9715fa14c5e5d1612301572cf1c6bbee" + +TASKS_SECRET="gT3BAytmNwhe1wKmvgREBlWcqK0=" + +EMAIL_USER="baptiste@xtablo.com" +EMAIL_CLIENT_ID="904332563417-e2n7pchtgnkrkp360baaebfeig55maig.apps.googleusercontent.com" \ No newline at end of file diff --git a/apps/api/src/routers/stripe.ts b/apps/api/src/routers/stripe.ts index 190201a..daa6204 100644 --- a/apps/api/src/routers/stripe.ts +++ b/apps/api/src/routers/stripe.ts @@ -68,6 +68,27 @@ const createCheckoutSession = ( return c.json({ error: "priceId is required" }, 400); } + const { data: price } = await supabase + .schema("stripe") + .from("prices") + .select("*") + .eq("id", priceId) + .maybeSingle(); + + if (!price) { + return c.json({ error: "Price not found" }, 404); + } + + const allowedInfiniteUsers = [ + "arbelleville@gmail.com", + "baptiste.belleville74@gmail.com", + "hugo@xtablo.com", + ]; + + if (price.unit_amount === 0 && !allowedInfiniteUsers.includes(user.email!)) { + return c.json({ error: "This price is not available" }, 400); + } + try { // Get or create Stripe customer let customerId: string; diff --git a/apps/main/.env.production b/apps/main/.env.production index 5119db4..44de9ae 100644 --- a/apps/main/.env.production +++ b/apps/main/.env.production @@ -4,9 +4,10 @@ VITE_SUPABASE_URL=https://mhcafqvzbrrwvahpvvzd.supabase.co VITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1oY2FmcXZ6YnJyd3ZhaHB2dnpkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDEyNDEzMjEsImV4cCI6MjA1NjgxNzMyMX0.Otxn5BWCPD2ABlMM59hCgeur9Tf_Q7PndAbTkqXDPtM VITE_SUPABASE_ID=mhcafqvzbrrwvahpvvzd -VITE_STREAM_CHAT_API_KEY="v4yf8rs94aa8" +VITE_STREAM_CHAT_API_KEY="h7bwnn8ynjpx" VITE_STRIPE_PUBLISHABLE_KEY=pk_live_51Qc159AmcXPHW4mTHUTW6it2mdZ3KQTxZGXZ188DKpXuXgpirUWOj24dnb7DzbcEAu45nU1S5k66Nm4liY3IlGOW00pndRsgUM -VITE_STRIPE_STANDARD_MONTHLY_PRICE_ID=price_1SPr3qAto3YQ7YhIALNeFBva +VITE_STRIPE_STANDARD_MONTHLY_PRICE_ID=price_1SO0HAAmcXPHW4mTkFIh3CvF +VITE_STRIPE_INFINITE_PRICE_ID=price_1SXHp8AmcXPHW4mTbus6j4Za VITE_API_URL=https://xablo-api-636270553187.europe-west1.run.app \ No newline at end of file diff --git a/apps/main/src/components/SubscriptionCard.tsx b/apps/main/src/components/SubscriptionCard.tsx index b934d5e..9c5ffc1 100644 --- a/apps/main/src/components/SubscriptionCard.tsx +++ b/apps/main/src/components/SubscriptionCard.tsx @@ -7,7 +7,6 @@ import { CardHeader, CardTitle, } from "@xtablo/ui/components/card"; -import { Text } from "@xtablo/ui/components/typography"; import { AlertCircle, CheckCircle2, CreditCard, Loader2Icon, Sparkles } from "lucide-react"; import { useCancelSubscription, @@ -21,6 +20,12 @@ import { useUser } from "../providers/UserStoreProvider"; import { pluralize } from "@xtablo/shared"; import { useMemo } from "react"; +const allowedInfiniteUsers = [ + "arbelleville@gmail.com", + "baptiste.belleville74@gmail.com", + "hugo@xtablo.com", +]; + /** * Subscription management card for Settings page * Shows current subscription status and allows users to upgrade/manage @@ -48,7 +53,14 @@ export function SubscriptionCard() { const showTrialBanner = user.plan === "none"; // Replace with your actual price ID from Stripe Dashboard - const STANDARD_MONTHLY_PRICE_ID = import.meta.env.VITE_STRIPE_STANDARD_MONTHLY_PRICE_ID || ""; + + const infinitePriceId = import.meta.env.VITE_STRIPE_INFINITE_PRICE_ID || ""; + const standardPriceId = import.meta.env.VITE_STRIPE_STANDARD_MONTHLY_PRICE_ID || ""; + + const priceId = + allowedInfiniteUsers.includes(user.email!) && infinitePriceId + ? infinitePriceId + : standardPriceId; const getStatusBadge = () => { // Check for beta plan first @@ -167,12 +179,12 @@ export function SubscriptionCard() { - {!STANDARD_MONTHLY_PRICE_ID && ( - - Configuration Stripe requise - - )} )}