Add Stripe payment integration for AI subscriptions
Implement subscription-based AI access with 250 generations/month at $5/month or $50/year. Changes: - Backend: Stripe service, payment routes, webhook handlers, generation tracking - Frontend: Upgrade page with pricing, payment success/cancel pages, UI prompts - Database: Add subscription fields to users, payments table, migrations - Config: Stripe env vars to .env.example, docker-compose.prod.yml, PRODUCTION.md - Tests: Payment route tests, component tests, subscription hook tests Users without AI access see upgrade prompts; subscribers see remaining generation count.
This commit is contained in:
parent
3c54a0f4d9
commit
2e12edc249
22 changed files with 2866 additions and 21 deletions
|
|
@ -204,6 +204,45 @@ The frontend is built inside Docker using the `KABOOT_DOMAIN` and `AUTH_DOMAIN`
|
|||
|
||||
The `setup-prod.sh` script sets these domain variables automatically.
|
||||
|
||||
### Stripe Payments Configuration (Optional)
|
||||
|
||||
To enable paid AI access subscriptions, configure Stripe:
|
||||
|
||||
```env
|
||||
# Stripe API Keys (get from https://dashboard.stripe.com/apikeys)
|
||||
STRIPE_SECRET_KEY=sk_live_... # Use sk_test_... for testing
|
||||
STRIPE_WEBHOOK_SECRET=whsec_... # From webhook endpoint configuration
|
||||
STRIPE_PRICE_ID_MONTHLY=price_... # Monthly subscription price ID
|
||||
STRIPE_PRICE_ID_YEARLY=price_... # Yearly subscription price ID
|
||||
```
|
||||
|
||||
#### Stripe Dashboard Setup
|
||||
|
||||
1. **Create a Product** in [Stripe Dashboard](https://dashboard.stripe.com/products):
|
||||
- Name: "Kaboot AI Pro"
|
||||
- Description: "250 AI quiz generations per month"
|
||||
|
||||
2. **Add Pricing**:
|
||||
- Monthly: $5.00/month (recurring)
|
||||
- Yearly: $50.00/year (recurring)
|
||||
- Copy the Price IDs (start with `price_`)
|
||||
|
||||
3. **Configure Webhook**:
|
||||
- Go to [Developers > Webhooks](https://dashboard.stripe.com/webhooks)
|
||||
- Add endpoint: `https://your-domain.com/api/payments/webhook`
|
||||
- Select events:
|
||||
- `checkout.session.completed`
|
||||
- `customer.subscription.updated`
|
||||
- `customer.subscription.deleted`
|
||||
- `invoice.paid`
|
||||
- `invoice.payment_failed`
|
||||
- Copy the Signing Secret (starts with `whsec_`)
|
||||
|
||||
4. **Test with Stripe CLI** (optional, for local development):
|
||||
```bash
|
||||
stripe listen --forward-to localhost:3001/api/payments/webhook
|
||||
```
|
||||
|
||||
## Docker Compose Files
|
||||
|
||||
The project includes pre-configured compose files:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue