Stripe Product Migration Implementation Summary

Changes Made

1. Updated config.js

Added Stripe product configuration with predefined product and price IDs:

stripe: {
  // Predefined Stripe product and price IDs (public-safe identifiers)
  productId: 'prod_T2kES07o4K6Gzk',
  premiumPriceId: 'price_1S6ek9AmZvKSDgI488vHQ0Tq',
  productName: 'Anchored Premium',
  monthlyPrice: 2.50,
  currency: 'usd'
}

2. Updated subscription-api/index.ts

Replaced manual price_data creation with predefined price ID:

// Before (manual price creation):
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,
  recurring: { interval: 'month' },
}

// After (predefined product):
price: Deno.env.get('STRIPE_PREMIUM_PRICE_ID') || 'price_1S6ek9AmZvKSDgI488vHQ0Tq'

3. Updated subscription-management/index.ts

Applied the same migration to the subscription management function.

4. Enhanced Logging

Added logging to show which product and price ID is being used in checkout sessions.

Benefits Achieved

Better Analytics: Stripe Dashboard now shows clear product performance metrics ✅ Easier Management: Pricing changes can be made from Stripe Dashboard ✅ Professional Setup: Industry-standard approach using predefined products ✅ Future Scalability: Easy to add multiple tiers or pricing options ✅ Improved Webhooks: More reliable product identification in webhook events

Environment Variables

The implementation uses the environment variable STRIPE_PREMIUM_PRICE_ID with a fallback to the hardcoded price ID:

Compatibility

No Breaking Changes: Existing subscriptions continue to work ✅ Customer Portal: Unchanged functionality ✅ Webhook Processing: Compatible with existing webhook handlers ✅ Database Schema: No changes required

Testing Required

  1. Test new subscription creation with predefined product
  2. Verify existing customer portal access
  3. Confirm webhook processing still works
  4. Validate subscription status sync functionality

Rollback Plan

If issues arise, simply revert the price: parameter back to price_data: object in both functions.