Backend API complete for NZD donation processing via Stripe. **New Backend Components:** Database Model: - src/models/Donation.model.js - Donation schema with privacy-first design - Anonymous donations by default, opt-in public acknowledgement - Monthly recurring and one-time donation support - Stripe integration (customer, subscription, payment tracking) - Public transparency metrics aggregation - Admin statistics and reporting Service Layer: - src/services/koha.service.js - Stripe integration service - Checkout session creation (monthly + one-time) - Webhook event processing (8 event types) - Subscription management (cancel, update) - Receipt email generation (placeholder) - Transparency metrics calculation - Based on passport-consolidated StripeService pattern Controller: - src/controllers/koha.controller.js - HTTP request handlers - POST /api/koha/checkout - Create donation checkout - POST /api/koha/webhook - Stripe webhook receiver - GET /api/koha/transparency - Public metrics - POST /api/koha/cancel - Cancel recurring donation - GET /api/koha/verify/:sessionId - Verify payment status - GET /api/koha/statistics - Admin statistics Routes: - src/routes/koha.routes.js - API endpoint definitions - src/routes/index.js - Koha routes registered **Infrastructure:** Server Configuration: - src/server.js - Raw body parsing for Stripe webhooks - Required for webhook signature verification - Route-specific middleware for /api/koha/webhook Environment Variables: - .env.example - Koha/Stripe configuration template - Stripe API keys (reuses passport-consolidated account) - Price IDs for NZD monthly tiers ($5, $15, $50) - Webhook secret for signature verification - Frontend URL for payment redirects **Documentation:** - docs/KOHA_STRIPE_SETUP.md - Complete setup guide - Step-by-step Stripe Dashboard configuration - Product and price creation instructions - Webhook endpoint setup - Testing procedures with test cards - Security and compliance notes - Production deployment checklist **Key Features:** ✅ Privacy-first design (anonymous by default) ✅ NZD currency support (New Zealand Dollars) ✅ Monthly recurring subscriptions ($5, $15, $50 NZD) ✅ One-time custom donations ✅ Public transparency dashboard metrics ✅ Stripe webhook signature verification ✅ Subscription cancellation support ✅ Receipt tracking (email generation ready) ✅ Admin statistics and reporting **Architecture:** - Reuses existing Stripe account from passport-consolidated - Separate webhook endpoint (/api/koha/webhook vs /api/stripe/webhook) - Separate MongoDB collection (koha_donations) - Compatible with existing infrastructure **Next Steps:** - Create Stripe products in Dashboard (use setup guide) - Build donation form frontend UI - Create transparency dashboard page - Implement receipt email service - Test end-to-end with Stripe test cards - Deploy to production 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
49 lines
1.2 KiB
Text
49 lines
1.2 KiB
Text
# Application
|
|
NODE_ENV=development
|
|
PORT=9000
|
|
APP_NAME=Tractatus
|
|
|
|
# MongoDB
|
|
MONGODB_URI=mongodb://localhost:27017/tractatus_dev
|
|
MONGODB_PORT=27017
|
|
MONGODB_DB=tractatus_dev
|
|
|
|
# JWT Authentication
|
|
JWT_SECRET=generate_a_secure_random_secret_key_here
|
|
JWT_EXPIRY=7d
|
|
|
|
# Admin
|
|
ADMIN_EMAIL=john.stroh.nz@pm.me
|
|
|
|
# Claude API (Phase 2+)
|
|
# CLAUDE_API_KEY=your_anthropic_api_key_here
|
|
# CLAUDE_MODEL=claude-sonnet-4-5
|
|
|
|
# Logging
|
|
LOG_LEVEL=info
|
|
LOG_FILE=logs/app.log
|
|
|
|
# Feature Flags
|
|
ENABLE_AI_CURATION=false
|
|
ENABLE_MEDIA_TRIAGE=false
|
|
ENABLE_CASE_SUBMISSIONS=false
|
|
|
|
# Security
|
|
RATE_LIMIT_WINDOW_MS=900000
|
|
RATE_LIMIT_MAX_REQUESTS=100
|
|
|
|
# Koha Donation System (Phase 3)
|
|
# Stripe configuration (reuses passport-consolidated account)
|
|
STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key_here
|
|
STRIPE_PUBLISHABLE_KEY=pk_test_your_stripe_publishable_key_here
|
|
STRIPE_KOHA_WEBHOOK_SECRET=whsec_your_webhook_secret_here
|
|
|
|
# Stripe Price IDs (NZD products)
|
|
# Create these in Stripe Dashboard first
|
|
STRIPE_KOHA_5_PRICE_ID=price_koha_5_nzd_monthly
|
|
STRIPE_KOHA_15_PRICE_ID=price_koha_15_nzd_monthly
|
|
STRIPE_KOHA_50_PRICE_ID=price_koha_50_nzd_monthly
|
|
STRIPE_KOHA_ONETIME_PRICE_ID=price_koha_onetime
|
|
|
|
# Frontend URL for redirects
|
|
FRONTEND_URL=http://localhost:9000
|