#!/bin/bash # Stripe Connect Setup Script for Black Canyon Tickets # Run this script to configure Firebase Functions for Stripe Connect set -e echo "🚀 Setting up Stripe Connect for Black Canyon Tickets" echo "==================================================" # Check if Firebase CLI is installed if ! command -v firebase &> /dev/null; then echo "❌ Firebase CLI not found. Install with: npm install -g firebase-tools" exit 1 fi # Check if logged in to Firebase if ! firebase projects:list &> /dev/null; then echo "⚠️ Not logged in to Firebase. Logging in..." firebase login fi # Set project echo "📁 Setting Firebase project to black-canyon-tickets..." firebase use black-canyon-tickets echo "" echo "🔑 You need to configure these environment variables:" echo "" echo "Required Stripe keys:" echo " - STRIPE_SECRET_KEY (from Stripe Dashboard)" echo " - STRIPE_WEBHOOK_SECRET (from webhook endpoint setup)" echo " - APP_URL (your application URL)" echo "" read -p "Enter your Stripe Secret Key (sk_test_...): " STRIPE_SECRET_KEY read -p "Enter your Stripe Webhook Secret (whsec_...): " STRIPE_WEBHOOK_SECRET read -p "Enter your App URL (e.g., https://portal.blackcanyontickets.com): " APP_URL if [ -z "$STRIPE_SECRET_KEY" ] || [ -z "$STRIPE_WEBHOOK_SECRET" ] || [ -z "$APP_URL" ]; then echo "❌ All fields are required. Please run the script again." exit 1 fi echo "" echo "🔧 Setting Firebase Functions configuration..." # Set environment variables firebase functions:config:set \ stripe.secret_key="$STRIPE_SECRET_KEY" \ stripe.webhook_secret="$STRIPE_WEBHOOK_SECRET" \ app.url="$APP_URL" echo "" echo "📦 Installing Functions dependencies..." cd functions npm install echo "" echo "🔨 Building Functions..." npm run build echo "" echo "✅ Setup complete!" echo "" echo "📋 Next steps:" echo "1. Deploy functions: firebase deploy --only functions" echo "" echo "2. Configure Stripe webhooks:" echo " Platform webhook URL: https://us-central1-black-canyon-tickets.cloudfunctions.net/stripeWebhook" echo " Events: account.updated" echo "" echo " Connect webhook URL: https://us-central1-black-canyon-tickets.cloudfunctions.net/stripeConnectWebhook" echo " Events: checkout.session.completed, payment_intent.succeeded" echo "" echo "3. Test the integration:" echo " - Start your React app: npm run dev" echo " - Navigate to /org/{orgId}/payments" echo " - Click 'Connect Stripe' to test onboarding" echo "" cd ..