![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/soundstudiopro.com/private_html/ |
# Monthly Subscription Package Analysis
## $5/month - 5 Tracks Per Month Package
### Current System Analysis
#### ✅ What Exists:
1. **Credit-based system** - Users buy credits, then use them for tracks
2. **Plans**: free, starter, pro, premium (one-time credit purchases)
3. **Track creation**: Costs 1 credit per track
4. **Database**: Has `subscription_expires` column (used for credit package expiration)
5. **Stripe integration**: Payment intents work, subscription webhooks exist but not fully implemented
6. **User plan field**: `users.plan` ENUM('free', 'starter', 'pro') - needs expansion
#### ❌ What's Missing:
1. **Recurring subscriptions** - No Stripe subscription setup
2. **Monthly track limits** - No tracking of tracks created per month
3. **Monthly reset system** - No cron job to reset monthly limits
4. **Subscription management** - No UI to manage subscriptions
5. **Track count tracking** - No table to track monthly track creation
### Implementation Requirements
#### 1. Database Changes Needed:
```sql
-- Add new plan to users table
ALTER TABLE users MODIFY COLUMN plan ENUM('free', 'essential', 'starter', 'pro', 'premium') DEFAULT 'free';
-- Create subscription tracking table
CREATE TABLE IF NOT EXISTS user_subscriptions (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
stripe_subscription_id VARCHAR(255) UNIQUE,
stripe_customer_id VARCHAR(255),
plan_name VARCHAR(50) NOT NULL,
status ENUM('active', 'canceled', 'past_due', 'unpaid') DEFAULT 'active',
current_period_start DATETIME,
current_period_end DATETIME,
cancel_at_period_end BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
INDEX idx_user (user_id),
INDEX idx_stripe_subscription (stripe_subscription_id),
INDEX idx_status (status)
);
-- Create monthly track usage table
CREATE TABLE IF NOT EXISTS monthly_track_usage (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
year_month VARCHAR(7) NOT NULL, -- Format: '2025-01'
tracks_created INT DEFAULT 0,
track_limit INT DEFAULT 0,
reset_at DATETIME,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY unique_user_month (user_id, year_month),
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
INDEX idx_user_month (user_id, year_month)
);
```
#### 2. Stripe Setup Required:
- Create a Product in Stripe Dashboard: "Essential Plan"
- Create a Price: $5/month recurring
- Get the `price_id` (starts with `price_`)
- Update webhook to handle subscription events
#### 3. Code Changes Needed:
**A. Track Creation Limit Check:**
- Before creating track, check monthly limit
- If limit reached, block creation
- Show message: "You've reached your monthly limit of 5 tracks. Upgrade or wait for next month."
**B. Subscription Signup:**
- Create Stripe Checkout Session for subscription
- Handle subscription creation webhook
- Set user plan to 'essential'
- Initialize monthly track usage
**C. Monthly Reset:**
- Cron job to reset track counts at start of each month
- Or reset when subscription renews
**D. Subscription Management:**
- UI to view subscription status
- Cancel subscription option
- Track usage display
### Safety Assessment
#### ✅ Safe to Implement:
- **Database changes**: Can be done safely with ALTER TABLE
- **New tables**: Won't affect existing functionality
- **Track limit check**: Additive, won't break existing credit system
- **Webhook handlers**: Already exist, just need to implement
#### ⚠️ Considerations:
- **Plan ENUM modification**: May need to handle existing 'premium' plan if it exists
- **Migration**: Existing users won't be affected (they stay on credit system)
- **Stripe setup**: Requires Stripe Dashboard configuration
- **Testing**: Should test with Stripe test mode first
### Implementation Steps
1. **Database Setup** (5 min)
- Run SQL to create tables and modify ENUM
- Verify no data loss
2. **Stripe Configuration** (10 min)
- Create product and price in Stripe
- Get price_id
- Configure webhook events
3. **Code Implementation** (30 min)
- Add subscription signup page
- Implement monthly limit check
- Update webhook handlers
- Add subscription management UI
4. **Testing** (15 min)
- Test subscription signup
- Test track limit enforcement
- Test monthly reset
- Test cancellation
### Estimated Time: ~1 hour
### Risk Level: **LOW** ✅
- Changes are additive
- Existing credit system remains intact
- Can be tested in isolation
- Easy to rollback if needed