I've developed a comprehensive settings system with full Stripe integration for SprintIQ. This implementation provides enterprise-grade subscription management, team administration, security controls, and API access management.
- Multi-tier Subscription Plans: Free, Pro ($99/mo), Growth ($299/mo), Enterprise (custom)
- Flexible Billing Cycles: Monthly and yearly billing with 17% annual discount
- Stripe Checkout Integration: Secure payment processing with redirect flow
- Customer Portal: Direct access to Stripe's customer portal for billing management
- Invoice Management: Complete invoice history with download capabilities
- Subscription Controls: Upgrade, downgrade, and cancel subscription functionality
- Plan Comparison: Feature-rich plan comparison with usage limits and capabilities
- Role-Based Access Control: Admin, Manager, Developer, and Viewer roles
- Team Invitations: Email-based invitation system with expiration
- Member Management: Add, remove, and update team member roles
- Permission Matrix: Detailed permissions overview for each role
- Activity Tracking: Last active timestamps and join dates
- Bulk Operations: Mass invitation and role updates
- Two-Factor Authentication: TOTP-based 2FA with backup codes
- Password Policies: Configurable complexity requirements and expiration
- Session Management: Timeout controls and concurrent session limits
- Access Control: IP whitelisting and geographic restrictions
- Audit Logging: Comprehensive security event tracking
- Suspicious Activity Detection: Automatic blocking of unusual patterns
- Granular Permissions: Fine-grained access control for API keys
- Key Lifecycle Management: Creation, rotation, and revocation
- Usage Tracking: Monitor API key usage and last access times
- Security Best Practices: Built-in security guidelines and warnings
- Documentation Integration: Links to API docs and SDKs
- Profile Customization: Personal preferences and localization
- Organization Configuration: Company details and integration settings
- Appearance Controls: Theme selection and interface density
- Notification Preferences: Comprehensive notification management
- Data Privacy Controls: GDPR-compliant data management options
src/components/settings/
├── billing-management.tsx # Stripe integration & subscription management
├── team-management.tsx # Team member & role management
├── security-settings.tsx # Security controls & policies
├── api-keys-management.tsx # API access management
└── [existing components] # Profile, notifications, etc.
src/app/api/
├── billing/
│ ├── create-checkout-session/ # Stripe checkout creation
│ ├── customer-portal/ # Stripe customer portal
│ ├── subscription/ # Subscription management
│ ├── invoices/ # Invoice retrieval
│ └── cancel-subscription/ # Subscription cancellation
└── settings/
├── api-keys/ # API key CRUD operations
└── security/ # Security settings management
- Subscription Creation: Stripe Checkout Sessions for plan upgrades
- Customer Portal: Direct integration for billing management
- Webhook Handling: Real-time subscription status updates
- Invoice Management: Automated invoice generation and retrieval
- Payment Method Updates: Secure card management through Stripe
- Plan Selection: User views plan comparison with feature matrix
- Checkout Process: Stripe Checkout handles secure payment
- Activation: Webhook confirms payment and activates features
- Management: Customer portal provides self-service billing
- Changes: Upgrade/downgrade through integrated flows
- Invitation: Admin sends role-based email invitations
- Registration: New members complete signup process
- Access Assignment: Automatic permission assignment based on role
- Onboarding: Guided setup for new team members
- Assessment: Security health check and recommendations
- Policy Setup: Configure password and session policies
- 2FA Enablement: QR code setup with backup codes
- Monitoring: Real-time security event tracking
- Up to 5 team members
- 1 repository connection
- Basic insights (10/month)
- 30-day data retention
- Email support
- Up to 25 team members
- Unlimited repositories
- Advanced insights (100/month)
- Real-time notifications
- Slack integration
- 1-year data retention
- Priority support
- Up to 100 team members
- Unlimited repositories
- Advanced insights (500/month)
- Custom dashboards
- All integrations (Jira, Linear, Zendesk)
- API access
- Unlimited data retention
- SLA support
- Unlimited team members
- Custom AI models
- White-label options
- SSO and advanced security
- Dedicated account manager
- 24/7 phone support
- Multi-Factor Authentication: TOTP-based with backup codes
- Role-Based Access Control: 4-tier permission system
- Session Security: Configurable timeouts and concurrent sessions
- API Security: Key-based authentication with granular permissions
- Encryption: AES-256 encryption at rest, TLS 1.3 in transit
- Data Retention: Configurable retention policies
- GDPR Compliance: Data export and deletion capabilities
- Audit Trails: Comprehensive activity logging
- IP Whitelisting: Restrict access by IP address/CIDR blocks
- Geographic Restrictions: Country-based access controls
- Suspicious Activity Detection: Automated threat detection
- Brute Force Protection: Rate limiting and account lockout
// Example Stripe setup
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY)
// Create checkout session
const session = await stripe.checkout.sessions.create({
mode: 'subscription',
payment_method_types: ['card'],
line_items: [{
price: priceMap[planId][billingInterval],
quantity: 1,
}],
success_url: `${process.env.NEXT_PUBLIC_APP_URL}/settings?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${process.env.NEXT_PUBLIC_APP_URL}/settings`,
client_reference_id: organizationId,
metadata: { organizationId, planId, billingInterval }
})// Secure API key generation
const generateApiKey = () => {
const prefix = 'spiq_live_'
const randomBytes = crypto.randomBytes(32)
const keyValue = prefix + randomBytes.toString('hex')
return keyValue
}// Role-based permissions
const PERMISSIONS = {
ADMIN: ['*'],
MANAGER: ['manage:team', 'view:analytics', 'manage:sprints'],
DEVELOPER: ['view:insights', 'manage:tasks', 'read:analytics'],
VIEWER: ['view:dashboards', 'read:reports']
}# Stripe Configuration
STRIPE_SECRET_KEY=sk_live_...
STRIPE_PUBLISHABLE_KEY=pk_live_...
STRIPE_WEBHOOK_SECRET=whsec_...
# Application URLs
NEXT_PUBLIC_APP_URL=https://your-domain.com
# Database
DATABASE_URL=postgresql://...
# Email Service
EMAIL_SERVICE_API_KEY=...- Configure webhook endpoint:
/api/webhooks/stripe - Subscribe to events:
customer.subscription.updated,invoice.payment_succeeded - Verify webhook signatures for security
Run migrations for:
- Subscription and billing tables
- API key management tables
- Security settings and audit logs
- Team management enhancements
- Monthly Recurring Revenue (MRR)
- Customer Lifetime Value (CLV)
- Churn rate and retention
- Plan upgrade/downgrade flows
- Failed login attempts
- API key usage patterns
- Suspicious activity alerts
- Compliance audit trails
- User adoption rates
- Feature usage by role
- Team growth metrics
- Support ticket analysis
- Usage-based billing for API calls
- Custom enterprise pricing
- Multi-currency support
- Tax calculation integration
- SSO integration (SAML, OIDC)
- Advanced threat detection
- Compliance certifications (SOC 2, ISO 27001)
- Zero-trust architecture
- Advanced permission granularity
- Team hierarchy management
- Workflow approvals
- Advanced audit capabilities
- Test mode for development
- Mock payment scenarios
- Webhook event simulation
- Error handling validation
- Penetration testing
- Vulnerability scanning
- Access control validation
- Audit trail verification
- Billing flow usability
- Team invitation process
- Settings configuration
- Mobile responsiveness
The comprehensive settings and Stripe integration transforms SprintIQ into an enterprise-ready SaaS platform with:
✅ Complete Subscription Management - From free trials to enterprise contracts
✅ Advanced Team Administration - Role-based access with granular controls
✅ Enterprise Security - 2FA, audit logs, and compliance features
✅ Developer-Friendly APIs - Secure key management with detailed permissions
✅ Scalable Architecture - Built to support teams from 5 to 500+ members
This implementation provides the foundation for SprintIQ's growth from startup tool to enterprise platform, with the flexibility to adapt to changing business needs and security requirements.