Skip to main content

Environment Configuration — PhotoSwipe Pro with AI SEO

This document explains all environment variables needed for payment processing, license validation, and AI features.

Quick Start

Copy the example below to your .env file or set in your deployment platform (Vercel, Netlify, Railway, etc.).

Payment Processing (LemonSqueezy)

Required Variables

# Get from https://app.lemonsqueezy.com/settings/api
LEMON_SQUEEZY_API_KEY=your_api_key_here

# Store ID from LS dashboard
LEMON_SQUEEZY_STORE_ID=12345

# Product Variant IDs (create products in LS first)
LEMON_SQUEEZY_VARIANT_ID_SITE=67890
LEMON_SQUEEZY_VARIANT_ID_AGENCY=67891

How to Get These Values

  1. API Key:

  2. Store ID:

  3. Variant IDs:

    • Create products in LS dashboard (Settings → Products)
    • For each product, create pricing variants (e.g., "Site License", "Agency License")
    • Click variant → URL shows variants/XXXXX → that's your Variant ID

License Validation

# Product ID for license validation (single product if all tiers share one)
LEMON_SQUEEZY_PRODUCT_ID=your_product_id

AI Provider (Optional)

# If using OpenAI for AI caption generation
OPENAI_API_KEY=sk-proj-...

# Or custom AI endpoint
AI_API_BASE_URL=https://your-ai-api.com/v1

Client-side Configuration

# Optional: Pre-configure a license key at build time
# Better to pass at runtime via plugin config
PSWP_PRO_KEY=pswp_paid_XXXX

Contact Information

# Displayed in checkout and support pages
SALES_EMAIL=sales@your-domain.com
SUPPORT_EMAIL=support@your-domain.com

Deployment Examples

Vercel

# Install Vercel CLI
npm i -g vercel

# Set environment variables
vercel env add LEMON_SQUEEZY_API_KEY
vercel env add LEMON_SQUEEZY_STORE_ID
vercel env add LEMON_SQUEEZY_VARIANT_ID_SITE
vercel env add LEMON_SQUEEZY_VARIANT_ID_AGENCY

# Deploy
vercel --prod

Or via Vercel dashboard:

  1. Go to Project → Settings → Environment Variables
  2. Add each variable for Production, Preview, and Development
  3. Redeploy

Netlify

# Set via Netlify CLI
netlify env:set LEMON_SQUEEZY_API_KEY "your_key"

# Or use netlify.toml

netlify.toml:

[build.environment]
# Don't put secrets here! Use Netlify dashboard instead

Via Netlify dashboard:

  1. Site Settings → Environment Variables
  2. Add variables
  3. Trigger new deploy

Railway

# Set via Railway CLI
railway variables set LEMON_SQUEEZY_API_KEY=your_key

# Or in dashboard: Variables tab

Docker / Self-hosted

Create .env file:

cp .env.example .env
# Edit .env with your values

Then:

docker run --env-file .env your-image

Security Notes

⚠️ Never commit .env to Git! Add to .gitignore:

.env
.env.local
.env.*.local

Server-side only: Payment and license secrets must NEVER be exposed to the browser. Our proxy architecture ensures secrets stay on the server.

Rotation: Rotate API keys quarterly or if compromised.

Testing

For development/testing:

# Use LemonSqueezy test mode
LEMON_SQUEEZY_API_KEY=test_key_...

# Or mock the payment provider
MOCK_PAYMENTS=true

Troubleshooting

"Payment system not configured"

  • Check /api/payment/health endpoint
  • Verify all required env vars are set
  • Restart your server after adding env vars

"Failed to create checkout"

"License validation failed"

  • Verify LEMON_SQUEEZY_PRODUCT_ID matches your LS product
  • Check license key format: pswp_paid_XXXX
  • Test via /api/license/validate endpoint

Next Steps

  1. Set up environment variables
  2. Deploy backend with server/payment/router.js and server/lemonsqueezy/router.js
  3. Test checkout flow: /checkout → select tier → complete test purchase
  4. Verify license delivery via email
  5. Test activation in demo or your site

See also: