The current implementation in supabase/functions/subscription-api/index.ts
creates checkout sessions manually using price_data
:
line_items: [
{
price_data: {
currency: 'usd',
product_data: {
name: 'Anchored Premium',
description: 'Cloud sync, web app access, unlimited exports, and 500 AI tokens per month',
},
unit_amount: 250, // $2.50 in cents
recurring: {
interval: 'month',
},
},
quantity: 1,
},
]
✅ Working Features:
Advantages:
Implementation Requirements:
// Instead of price_data, use:
line_items: [
{
price: 'price_1234567890abcdef', // Predefined price ID
quantity: 1,
},
]
Advantages:
Disadvantages:
✅ Fully Compatible: The current system would work seamlessly with predefined products because:
profiles
table structure supports any subscription typeMinimal Changes Needed:
price_data
with price
parameter in checkout session# Create product in Stripe Dashboard or via API
curl https://api.stripe.com/v1/products \
-u sk_test_... \
-d name="Anchored Premium" \
-d description="Cloud sync, web app access, unlimited exports, and 500 AI tokens per month"
# Create price for the product
curl https://api.stripe.com/v1/prices \
-u sk_test_... \
-d product=prod_... \
-d unit_amount=250 \
-d currency=usd \
-d "recurring[interval]"=month
Add to config.js
:
stripe: {
premiumPriceId: 'price_1234567890abcdef', // From Stripe Dashboard
productId: 'prod_1234567890abcdef'
}
Replace price_data
with price
in subscription-api/index.ts
:
line_items: [
{
price: config.stripe.premiumPriceId,
quantity: 1,
},
]
Update webhook to handle product-specific events for better reliability.
Low Risk Migration:
Recommendation: YES, migrate to Stripe products
The migration is:
The current system is fully compatible and the migration would be straightforward with immediate benefits for business monitoring and future scalability.