Your website now includes a fully functional e-commerce store with:
- Product catalog with real-time inventory
- Shopping cart with quantity management
- Employee discount system with unique coupon codes
- Stripe payment integration
- Order confirmation
- Browse CCI branded merchandise
- Add products to cart with size selection
- Secure checkout with Stripe
- Order confirmation emails (configured in Stripe)
- Enter unique coupon codes at checkout
- Get products at cost (percentage discount)
- Track usage per employee
- Coupon validation in real-time
- Go to stripe.com and sign up
- Complete account setup
- Get your API keys from Dashboard > Developers > API Keys
Create a .env.local file in the project root:
cp .env.local.example .env.localEdit .env.local and add your Stripe keys:
# Test mode keys (for development)
STRIPE_SECRET_KEY=sk_test_YOUR_TEST_SECRET_KEY
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_YOUR_TEST_PUBLISHABLE_KEY
# Base URL
NEXT_PUBLIC_BASE_URL=http://localhost:3000Important: Never commit .env.local to git! It's already in .gitignore.
Use these test card numbers in Stripe test mode:
- Success:
4242 4242 4242 4242 - Decline:
4000 0000 0000 0002 - Use any future expiration date and any 3-digit CVC
Edit /lib/data/products.ts to customize your merchandise:
{
id: "product-id",
name: "Product Name",
description: "Product description",
price: 2500, // Price in cents ($25.00)
cost: 1200, // Cost in cents ($12.00) for employee discount
image: "/images/merch/product.png",
category: "apparel" | "gear" | "accessories",
sizes: ["S", "M", "L", "XL"], // Optional
inStock: true,
}Add product photos to /public/images/merch/:
tshirt.pnghoodie.pnghat.pngmug.pngstickers.png
Recommended image size: 800x800px (square)
The system includes 3 sample employee codes (in /lib/data/coupons.ts):
EMP-JOHN-2024(52% discount)EMP-JANE-2024(52% discount)EMP-MIKE-2024(52% discount)
- Employee adds products to cart
- At checkout, enters unique coupon code
- System validates code via API
- If valid, applies percentage discount
- Employee pays cost price instead of retail
Edit /lib/data/coupons.ts:
{
code: "EMP-SARAH-2024",
employeeName: "Sarah Wilson",
discountPercent: 52, // Adjust based on your markup
isActive: true,
usageCount: 0,
createdAt: new Date(),
}Build an admin page at /admin/coupons to:
- Generate new codes automatically
- View usage statistics
- Activate/deactivate codes
- Set usage limits
Note: In production, you should move coupons to a database (PostgreSQL, MongoDB, etc.) instead of the in-memory array.
To calculate the discount needed to bring retail to cost:
discountPercent = ((retail - cost) / retail) Γ 100
Example:
- Retail: $25.00
- Cost: $12.00
- Discount: ((25 - 12) / 25) Γ 100 = 52%
In Stripe Dashboard:
- Toggle from "Test mode" to "Live mode"
- Get your production API keys
- Update
.env.localwith live keys:
STRIPE_SECRET_KEY=sk_live_YOUR_LIVE_SECRET_KEY
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_YOUR_LIVE_PUBLISHABLE_KEY
NEXT_PUBLIC_BASE_URL=https://your-domain.vercel.app# Push your code
git add .
git commit -m "Add merchandise store"
git push
# In Vercel Dashboard:
# 1. Go to your project settings
# 2. Add environment variables:
# - STRIPE_SECRET_KEY
# - NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
# - NEXT_PUBLIC_BASE_URL
# 3. RedeployFor order tracking and email confirmations:
- Go to Stripe Dashboard > Developers > Webhooks
- Add endpoint:
https://your-domain.vercel.app/api/webhooks/stripe - Select events:
checkout.session.completedpayment_intent.succeeded
- Copy webhook secret and add to Vercel env vars:
STRIPE_WEBHOOK_SECRET
All orders appear in your Stripe Dashboard:
- Dashboard > Payments
- Filter by status, amount, date
- Export to CSV for accounting
Customer information (name, email, address) is collected during Stripe Checkout and stored in Stripe.
Access via:
- Stripe Dashboard > Customers
- Or programmatically via Stripe API
The store uses your existing brand colors (#f66400 orange, #000000 black).
To customize, edit components in /app/merch/:
page.tsx- Product listingcart/page.tsx- Shopping cart
- Update product type in
/lib/data/products.ts:
category: "apparel" | "gear" | "accessories" | "new-category"- Add filtering on the merch page (optional)
By default, Stripe Checkout doesn't collect shipping info. To enable:
In /app/api/checkout/route.ts, add to session creation:
shipping_address_collection: {
allowed_countries: ["US", "CA"], // Add your countries
}- Track stock levels in database
- Update
inStockstatus automatically - Send low-stock alerts
- Integrate with fulfillment service (Printful, Printify)
- Or build custom fulfillment dashboard
- Track best-selling products
- Monitor employee discount usage
- Revenue reports
- Send custom order confirmations
- Use SendGrid, Resend, or Mailgun
- Include order details and tracking
- Never expose secret keys: Keep
STRIPE_SECRET_KEYserver-side only - Validate on server: Always validate coupons server-side (done)
- Use HTTPS: Vercel provides this automatically
- Monitor for fraud: Check Stripe Radar for suspicious activity
- Check that environment variables are set
- Restart dev server after adding .env.local
- Verify Stripe keys are correct (test vs live)
- Check browser console for errors
- Verify BASE_URL matches your domain
- Check code matches exactly (case-sensitive converted to uppercase)
- Verify coupon is active in
/lib/data/coupons.ts - Check browser network tab for API errors
- Stripe Documentation: docs.stripe.com
- Stripe Support: Available in your dashboard
- Test Cards: stripe.com/docs/testing
Your merch store is ready to generate revenue! π