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
API Key:
- Go to https://app.lemonsqueezy.com/settings/api
- Create a new API key with "Read" and "Write" permissions
- Copy the key (starts with
lemon_squeezy_)
Store ID:
- Go to https://app.lemonsqueezy.com/settings/stores
- Click your store → URL shows
stores/XXXXX→ that's your Store ID
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:
- Go to Project → Settings → Environment Variables
- Add each variable for Production, Preview, and Development
- 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:
- Site Settings → Environment Variables
- Add variables
- 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/healthendpoint - Verify all required env vars are set
- Restart your server after adding env vars
"Failed to create checkout"
- Verify Variant IDs exist in your LemonSqueezy store
- Check API key has "Write" permissions
- Check LemonSqueezy API status: https://status.lemonsqueezy.com
"License validation failed"
- Verify
LEMON_SQUEEZY_PRODUCT_IDmatches your LS product - Check license key format:
pswp_paid_XXXX - Test via
/api/license/validateendpoint
Next Steps
- Set up environment variables
- Deploy backend with
server/payment/router.jsandserver/lemonsqueezy/router.js - Test checkout flow:
/checkout→ select tier → complete test purchase - Verify license delivery via email
- Test activation in demo or your site
See also: