Epic 5.0 - E-commerce & Self-Service Checkout
This guide explains how to set up Stripe payment processing for the self-service subscription checkout flow.
- Stripe account (sign up at https://stripe.com)
- Access to Stripe Dashboard
- Ops Center backend running
- Log in to Stripe Dashboard
- Ensure you're in Test mode (toggle in top-right)
- Navigate to Developers → API keys
- Copy the following keys:
- Publishable key (starts with
pk_test_) - Secret key (starts with
sk_test_)
- Publishable key (starts with
- Complete Stripe account activation
- Switch to Live mode in Stripe Dashboard
- Navigate to Developers → API keys
- Copy the following keys:
- Publishable key (starts with
pk_live_) - Secret key (starts with
sk_live_)
- Publishable key (starts with
For each subscription tier (trial, starter, byok, managed, vip_founder, enterprise):
- Go to Products → Add product in Stripe Dashboard
- Create product:
- Name: Tier name (e.g., "Starter Plan")
- Description: Tier description
- Pricing model: Recurring
- Billing period: Monthly
- Price: Set monthly price (e.g., $29.00)
- Click Save product
- Note the Price ID (starts with
price_) - Click Add another price to create yearly pricing:
- Billing period: Yearly
- Price: Set annual price (e.g., $278.40 for 20% discount)
- Click Save
- Note the Yearly Price ID
Trial Tier:
- Product ID: prod_xxx
- Monthly Price ID: price_trial_monthly (Price: $0.00)
- Yearly Price ID: price_trial_yearly (Price: $0.00)
Starter Tier:
- Product ID: prod_yyy
- Monthly Price ID: price_starter_monthly (Price: $29.00)
- Yearly Price ID: price_starter_yearly (Price: $278.40)
... repeat for all tiers
Connect to PostgreSQL and update the subscription_tiers table:
-- Update Trial tier
UPDATE subscription_tiers
SET
stripe_price_monthly = 'price_trial_monthly_id_here',
stripe_price_yearly = 'price_trial_yearly_id_here'
WHERE tier_code = 'trial';
-- Update Starter tier
UPDATE subscription_tiers
SET
stripe_price_monthly = 'price_starter_monthly_id_here',
stripe_price_yearly = 'price_starter_yearly_id_here'
WHERE tier_code = 'starter';
-- Repeat for all tiers: byok, managed, vip_founder, enterprise# SSH into server
ssh ubuntu@kubeworkz.io
# Connect to PostgreSQL
docker exec -it ops-center-postgresql psql -U unicorn -d unicorn_db
# Run updates
UPDATE subscription_tiers SET stripe_price_monthly = 'price_xxx', stripe_price_yearly = 'price_yyy' WHERE tier_code = 'trial';
UPDATE subscription_tiers SET stripe_price_monthly = 'price_xxx', stripe_price_yearly = 'price_yyy' WHERE tier_code = 'starter';
UPDATE subscription_tiers SET stripe_price_monthly = 'price_xxx', stripe_price_yearly = 'price_yyy' WHERE tier_code = 'byok';
UPDATE subscription_tiers SET stripe_price_monthly = 'price_xxx', stripe_price_yearly = 'price_yyy' WHERE tier_code = 'managed';
UPDATE subscription_tiers SET stripe_price_monthly = 'price_xxx', stripe_price_yearly = 'price_yyy' WHERE tier_code = 'vip_founder';
UPDATE subscription_tiers SET stripe_price_monthly = 'price_xxx', stripe_price_yearly = 'price_yyy' WHERE tier_code = 'enterprise';Add Stripe keys to your environment:
Create or update .env file in project root:
# Stripe Configuration
STRIPE_PUBLISHABLE_KEY=pk_test_your_publishable_key_here
STRIPE_SECRET_KEY=sk_test_your_secret_key_here
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret_hereexport STRIPE_PUBLISHABLE_KEY=pk_test_your_publishable_key_here
export STRIPE_SECRET_KEY=sk_test_your_secret_key_here
export STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret_hereEdit the environment section (lines 93-96) with actual values:
- STRIPE_PUBLISHABLE_KEY=pk_test_actual_key_here
- STRIPE_SECRET_KEY=sk_test_actual_key_here
- STRIPE_WEBHOOK_SECRET=whsec_actual_secret_hereApply the new environment variables:
cd /home/ubuntu/Ops-Center-OSS
docker-compose -f docker-compose.direct.yml restart ops-center-directTo receive real-time payment events:
- Go to Developers → Webhooks in Stripe Dashboard
- Click Add endpoint
- Endpoint URL:
https://kubeworkz.io/api/v1/checkout/webhook - Events to send:
checkout.session.completedcustomer.subscription.createdcustomer.subscription.updatedcustomer.subscription.deletedpayment_intent.succeededpayment_intent.payment_failed
- Click Add endpoint
- Copy the Signing secret (starts with
whsec_) - Update
STRIPE_WEBHOOK_SECRETenvironment variable - Restart backend
Install Stripe CLI: https://stripe.com/docs/stripe-cli
# Login to Stripe
stripe login
# Forward webhooks to local server
stripe listen --forward-to http://localhost:8084/api/v1/checkout/webhook
# Copy the webhook signing secret and set it:
export STRIPE_WEBHOOK_SECRET=whsec_from_cli_output- Navigate to:
https://kubeworkz.io/pricing - Select a tier and billing cycle
- Click "Get Started"
- Enter test email on checkout page
- Click "Continue to Payment"
- You should be redirected to Stripe Checkout
Use these test card numbers in Stripe Checkout:
Successful Payment:
- Card:
4242 4242 4242 4242 - Expiry: Any future date (e.g.,
12/34) - CVC: Any 3 digits (e.g.,
123) - ZIP: Any 5 digits (e.g.,
12345)
Payment Requires Authentication (3D Secure):
- Card:
4000 0025 0000 3155
Payment Declined:
- Card:
4000 0000 0000 0002
Insufficient Funds:
- Card:
4000 0000 0000 9995
Full list: https://stripe.com/docs/testing#cards
Check backend logs for webhook processing:
docker logs ops-center-direct -f | grep "Checkout completed"After a successful test payment, verify the subscription was created:
-- Check if customer was created
SELECT * FROM stripe_customers WHERE email = 'test@example.com';
-- Check if subscription was created
SELECT * FROM subscriptions WHERE customer_email = 'test@example.com';# Get Stripe config
curl https://kubeworkz.io/api/v1/checkout/config
# Create checkout session
curl -X POST https://kubeworkz.io/api/v1/checkout/create-session \
-H "Content-Type: application/json" \
-d '{
"tier_code": "starter",
"billing_cycle": "monthly",
"email": "customer@example.com"
}'
# Get session status
curl https://kubeworkz.io/api/v1/checkout/session/cs_test_xxx# Get all tiers
curl https://kubeworkz.io/api/v1/public/tiers
# Get tier features
curl https://kubeworkz.io/api/v1/public/tiers/starter/featuresSolution: Ensure STRIPE_SECRET_KEY and STRIPE_PUBLISHABLE_KEY are set and restart backend
Solution: Update stripe_price_yearly in database for that tier
Solution:
- Verify
STRIPE_WEBHOOK_SECRETmatches the secret from Stripe Dashboard - Check webhook endpoint URL is correct
- Ensure webhook is receiving events (check Stripe Dashboard → Webhooks → View logs)
Solution:
- Verify Price ID exists in Stripe Dashboard
- Ensure Price ID in database matches exactly
- Check Price is active (not archived)
- Never commit API keys to Git
- Use test mode for development
- Use environment variables for sensitive data
- Verify webhook signatures in production
- Use HTTPS for webhook endpoints
- Rotate keys periodically
- Monitor Stripe Dashboard for suspicious activity
- Enable Stripe Radar for fraud detection
- Switch from test keys to live keys
- Update all Stripe Price IDs in database to live prices
- Configure production webhook endpoint
- Test end-to-end flow with live cards (small amount)
- Enable Stripe Radar fraud protection
- Set up email notifications for failed payments
- Configure tax calculation (if applicable)
- Enable customer portal for subscription management
- Document refund process
- Train support team on Stripe Dashboard
After Stripe integration is complete:
- Subscription Management: Implement upgrade/downgrade flows
- Trial Management: Automate trial expiry and conversion
- Invoice Generation: Email receipts and invoices
- Payment Methods: Allow customers to update cards
- Cancellation Flow: Handle subscription cancellations
- Webhook Testing: Comprehensive webhook event handling
- Analytics: Track conversion rates and revenue
- Stripe Documentation
- Stripe API Reference
- Stripe Testing Guide
- Stripe Webhooks Guide
- Stripe Security
For issues with this integration:
- Check logs:
docker logs ops-center-direct -f - Review Stripe Dashboard for errors
- Contact support team