# Stripe Payment Setup Instructions

## Quick Start

1. **Install dependencies:**
   ```bash
   npm install
   ```

2. **Create a `.env` file** in the root directory with the following content:
   ```
   STRIPE_SECRET_KEY=sk_test_your_secret_key_here
   STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret_here
   PORT=3000
   NODE_ENV=development

   # Contact form (Brevo — https://developers.brevo.com/docs/getting-started )
   BREVO_API_KEY=xkeysib-xxxxxxxx
   CONTACT_TO_EMAIL=you@yourdomain.com
   CONTACT_FROM_EMAIL=hello@your-verified-sender.com
   CONTACT_FROM_NAME=OneStep Wellness
   ```
   Create an API key under Brevo **SMTP & API**, and add a [verified sender](https://help.brevo.com/hc/en-us/articles/208836149). Use that sender’s email for `CONTACT_FROM_EMAIL`. Optional: use `Name <email>` in `CONTACT_FROM_EMAIL` instead of separate `CONTACT_FROM_NAME`.

3. **Get your Stripe API keys:**
   - Sign up at https://stripe.com (or log in if you have an account)
   - Go to https://dashboard.stripe.com/apikeys
   - Copy your **Secret key** (starts with `sk_test_` for test mode)
   - Replace `sk_test_your_secret_key_here` in your `.env` file

4. **Build TypeScript:**
   ```bash
   npm run build
   ```

5. **Start the server:**
   ```bash
   # Production
   npm start
   
   # Development (with hot reload)
   npm run dev
   ```

6. **Access the site:**
   - Open http://localhost:3000 in your browser
   - Navigate to http://localhost:3000/pages/checkout.html (or `/checkout.html`) to test payments

## Testing Payments

Use Stripe's test card numbers:
- **Success:** 4242 4242 4242 4242
- **Decline:** 4000 0000 0000 0002
- Use any future expiry date, any 3-digit CVC, and any ZIP code

## Production Setup

1. **Switch to live mode:**
   - Get your live API keys from Stripe Dashboard
   - Update `.env` with live keys (starts with `sk_live_`)

2. **Set up webhooks:**
   - In Stripe Dashboard, go to Developers > Webhooks
   - Add endpoint: `https://yourdomain.com/api/webhook`
   - Select events: `checkout.session.completed`
   - Copy the webhook signing secret to `STRIPE_WEBHOOK_SECRET` in `.env`

3. **Update prices:**
   - Edit the `SERVICES` object in `src/config/services.ts` to match your actual pricing
   - Or create Products and Prices in Stripe Dashboard and use Price IDs instead
   - Rebuild after changes: `npm run build`

## Available Services

The checkout system includes these services (prices in `server.js`):
- Personal Training (single or 4-pack)
- Coaching Sessions (single or 4-pack)
- Therapy Sessions (individual, couples, single or 4-pack)
- Online Coaching Courses
- Consultations

## Troubleshooting

- **"Invalid API Key"**: Make sure your `.env` file has the correct Stripe secret key
- **CORS errors**: The server includes CORS middleware, but check your browser console
- **Webhook errors**: Make sure `STRIPE_WEBHOOK_SECRET` matches your webhook endpoint secret

