WHAT WAS DONE: - Created src/routes/stripe.js with 3 endpoints: * POST /stripe/create-checkout-session (dynamic mode: subscription or payment) * POST /stripe/webhook (signature verified, transaction-safe, idempotent) * POST /stripe/create-portal-session (Stripe Customer Portal access) - Updated package.json to add stripe@^14.14.0 dependency - Updated src/index.js to register Stripe routes (webhook BEFORE body parsers - critical!) - Updated .env.example with STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET, BASE_URL WHY: - Eliminates Paymenter dependency (Gemini-approved architecture) - Handles both recurring subscriptions (tiers 2-9) and one-time payments (Awakened, Sovereign) - Webhook processes 8 event types with full transaction safety - Grace period system for failed payments (3-day countdown, auto-downgrade to Awakened) - Chargeback = immediate permanent ban - Idempotency protection via webhook_events_processed table TECHNICAL DETAILS: - Checkout dynamically switches mode based on billing_type (recurring vs one-time) - Webhook uses BEGIN/COMMIT/ROLLBACK for all database operations - Raw body parser for webhook signature verification (must come before express.json()) - Supports Stripe Customer Portal for self-service subscription management - Handles both stripe_subscription_id and stripe_payment_intent_id correctly - Grace period logic excludes lifetime users (is_lifetime = TRUE) FILES CHANGED: - services/arbiter-3.0/src/routes/stripe.js (new, 421 lines) - services/arbiter-3.0/package.json (added stripe dependency) - services/arbiter-3.0/src/index.js (registered stripe routes, webhook ordering) - services/arbiter-3.0/.env.example (added Stripe env vars) NEXT STEPS: - Deploy to Command Center - Add STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET to production .env - Configure Stripe webhook endpoint in Dashboard - Test end-to-end in test mode - Switch to live mode for launch Signed-off-by: Claude (Chronicler #57) <claude@firefrostgaming.com>
26 lines
619 B
JSON
26 lines
619 B
JSON
{
|
|
"name": "arbiter-3.0",
|
|
"version": "3.0.0",
|
|
"description": "Modular Access & Role Manager with Trinity Console",
|
|
"main": "src/index.js",
|
|
"scripts": {
|
|
"start": "node src/index.js",
|
|
"dev": "node --watch src/index.js"
|
|
},
|
|
"dependencies": {
|
|
"body-parser": "^1.20.2",
|
|
"cookie-parser": "^1.4.7",
|
|
"csurf": "^1.11.0",
|
|
"discord.js": "^14.14.1",
|
|
"dotenv": "^16.4.5",
|
|
"ejs": "^3.1.9",
|
|
"express": "^4.18.2",
|
|
"express-session": "^1.19.0",
|
|
"node-cron": "^3.0.3",
|
|
"passport": "^0.7.0",
|
|
"passport-discord": "^0.1.4",
|
|
"pg": "^8.11.3",
|
|
"stripe": "^14.14.0"
|
|
}
|
|
}
|