Finish stripe integration for MVP
This commit is contained in:
parent
ebc65ef000
commit
1342f69efa
2 changed files with 21 additions and 9 deletions
|
|
@ -68,6 +68,23 @@ 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"];
|
||||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
@ -38,7 +37,8 @@ export function SubscriptionCard() {
|
|||
const isBeta = user.plan === "beta";
|
||||
|
||||
// Replace with your actual price ID from Stripe Dashboard
|
||||
const STANDARD_MONTHLY_PRICE_ID = import.meta.env.VITE_STRIPE_STANDARD_MONTHLY_PRICE_ID || "";
|
||||
|
||||
const priceId = import.meta.env.VITE_STRIPE_STANDARD_MONTHLY_PRICE_ID || "";
|
||||
|
||||
const getStatusBadge = () => {
|
||||
// Check for beta plan first
|
||||
|
|
@ -156,12 +156,12 @@ export function SubscriptionCard() {
|
|||
<Button
|
||||
onClick={() =>
|
||||
createCheckout({
|
||||
priceId: STANDARD_MONTHLY_PRICE_ID,
|
||||
priceId: priceId,
|
||||
successUrl: `${window.location.origin}/settings?success=true`,
|
||||
cancelUrl: `${window.location.origin}/settings?canceled=true`,
|
||||
})
|
||||
}
|
||||
disabled={checkoutPending || !STANDARD_MONTHLY_PRICE_ID}
|
||||
disabled={checkoutPending || !priceId}
|
||||
className="w-full gap-2 bg-gradient-to-r from-purple-500 to-blue-500 hover:from-purple-600 hover:to-blue-600"
|
||||
>
|
||||
{checkoutPending ? (
|
||||
|
|
@ -176,11 +176,6 @@ export function SubscriptionCard() {
|
|||
</>
|
||||
)}
|
||||
</Button>
|
||||
{!STANDARD_MONTHLY_PRICE_ID && (
|
||||
<Text className="text-xs text-red-600 dark:text-red-400">
|
||||
Configuration Stripe requise
|
||||
</Text>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue