Stripe Product vs Manual Checkout Session Analysis

Current Implementation Analysis

How It Currently Works

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,
  },
]

Current System Capabilities

Working Features:

Stripe Product Approach vs Current Manual Approach

Advantages:

Implementation Requirements:

// Instead of price_data, use:
line_items: [
  {
    price: 'price_1234567890abcdef', // Predefined price ID
    quantity: 1,
  },
]

Option 2: Current Manual Approach

Advantages:

Disadvantages:

Compatibility Assessment

Current System Compatibility with Stripe Products

Fully Compatible: The current system would work seamlessly with predefined products because:

  1. Customer Management: Already properly creates and manages Stripe customers
  2. Subscription Handling: Uses standard Stripe subscription objects
  3. Portal Integration: Customer portal works with any subscription type
  4. Webhook Processing: Can be easily updated to handle product-specific events
  5. Database Schema: Current profiles table structure supports any subscription type

Migration Requirements

Minimal Changes Needed:

  1. Create Stripe product and price in Stripe Dashboard
  2. Replace price_data with price parameter in checkout session
  3. Update webhook handler to process product-specific events (optional)
  4. Add product ID to configuration (recommended)

Recommendation: Migrate to Stripe Products

Why Migrate?

  1. Professional Setup: More professional and scalable approach
  2. Better Monitoring: Easier to track business metrics
  3. Future-Proofing: Easier to add new tiers or change pricing
  4. Industry Standard: Most SaaS applications use predefined products

Migration Plan

Step 1: Create Stripe Product

# 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

Step 2: Update Configuration

Add to config.js:

stripe: {
  premiumPriceId: 'price_1234567890abcdef', // From Stripe Dashboard
  productId: 'prod_1234567890abcdef'
}

Step 3: Update Checkout Session Creation

Replace price_data with price in subscription-api/index.ts:

line_items: [
  {
    price: config.stripe.premiumPriceId,
    quantity: 1,
  },
]

Step 4: Enhanced Webhook Handling (Optional)

Update webhook to handle product-specific events for better reliability.

Risk Assessment

Low Risk Migration:

Conclusion

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.