Subscription Plans
Available Plans
The starter kit includes predefined subscription plans in lib/payment/plans.ts
. You can customize these plans or add new ones:
export const plans = {
free: {
name: "Free",
description: "Basic features",
price: "$0",
features: ["Limited AI interactions", "Basic support"]
},
pro: {
name: "Pro",
description: "Advanced features",
price: "$10/month",
features: ["Unlimited AI interactions", "Priority support"]
}
};
Payment Flow
Checkout Process
- User selects a plan or credit bundle
- System creates a Stripe checkout session
- User completes payment on Stripe's hosted page
- Webhook receives payment confirmation
- System updates user's credits or subscription status
Example: Processing a Payment
// Client-side: Initiating checkout
async function handleCheckout() {
const response = await fetch('/api/stripe/checkout/subscription', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ priceId: plans[0].yearly.priceId })
});
const { url } = await response.json();
window.location.href = url;
}