![]() 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/ |
# Invoice Access Summary
## ✅ What We Have
### 1. **Stripe Invoice Access**
- ✅ **Full API Access**: We can fetch all invoices for any customer via Stripe API
- ✅ **Invoice Data Available**:
- Invoice number
- Date created
- Amount paid/due
- Status (paid, open, draft, void, uncollectible)
- Description/line items
- PDF download link (`invoice_pdf`)
- Hosted invoice URL (`hosted_invoice_url`)
- Subscription ID (if subscription-related)
### 2. **New Invoice Page** (`/invoices.php`)
- ✅ **User-facing page** to view all their invoices
- ✅ **Fetches invoices** from Stripe API using customer ID
- ✅ **Displays**:
- Invoice number
- Date
- Description
- Amount
- Status badge
- Download PDF button (if available)
- View Invoice link (if hosted URL available)
### 3. **Integration Points**
- ✅ **Link in Manage Subscription** (`/manage_subscription.php`)
- ✅ **Link in Account Settings** (`/account_settings.php` - Credits tab)
- ✅ **Accessible to all users** with Stripe customer ID
---
## 📋 How It Works
### For Subscription Users:
1. User subscribes → Stripe creates invoice automatically
2. Invoice is available in Stripe immediately
3. User can view/download from `/invoices.php`
4. Each monthly renewal creates a new invoice
### For Credit Package Purchases:
1. User purchases credits → Payment Intent created
2. If using subscriptions, invoice may be created
3. Invoice appears in `/invoices.php` if customer ID exists
### For Track Purchases:
1. User purchases track → Payment Intent created
2. Invoice may be created depending on payment method
3. Invoice appears in `/invoices.php` if customer ID exists
---
## 🔧 Technical Details
### API Endpoint Used:
```
GET https://api.stripe.com/v1/invoices?customer={customer_id}&limit=100
```
### Invoice Fields We Display:
- `id` - Invoice ID
- `number` - Human-readable invoice number
- `created` - Unix timestamp
- `amount_paid` - Amount paid in cents
- `amount_due` - Amount due in cents
- `status` - paid, open, draft, void, uncollectible
- `description` - Invoice description
- `invoice_pdf` - Direct PDF download URL
- `hosted_invoice_url` - Stripe-hosted invoice page
- `subscription` - Subscription ID (if applicable)
### Access Requirements:
- User must be logged in
- User must have `stripe_customer_id` in database
- Stripe API key must be configured
---
## 🎯 User Experience
### Viewing Invoices:
1. User goes to `/invoices.php` or clicks "View Invoices" button
2. Page fetches invoices from Stripe
3. Invoices displayed in reverse chronological order (newest first)
4. Each invoice shows:
- Invoice number and date
- Description (subscription name or purchase details)
- Amount paid
- Status badge
- Download/view button
### Downloading Invoices:
- **PDF Download**: Direct link to Stripe-hosted PDF (if available)
- **Hosted View**: Opens Stripe's invoice page in new tab (if available)
- **Fallback**: If neither available, invoice still visible but no download option
---
## ⚠️ Limitations
### Current Limitations:
1. **No Local Storage**: Invoices are fetched from Stripe each time (not cached)
2. **No Invoice Filtering**: Shows all invoices (could add date/status filters)
3. **No Invoice Search**: No search functionality
4. **No Email Notifications**: Stripe sends invoice emails, but we don't send our own
5. **Credit Purchases**: May not always create invoices (depends on payment method)
### Future Enhancements:
- Cache invoices in database for faster loading
- Add date range filtering
- Add search by invoice number
- Add email notifications when new invoice created
- Store invoice IDs in database for quick reference
---
## 📊 Invoice Types
### Subscription Invoices:
- **Created**: Automatically by Stripe on subscription creation and renewal
- **Frequency**: Monthly (or based on subscription billing cycle)
- **Contains**: Subscription plan name, amount, billing period
### One-Time Payment Invoices:
- **Created**: When payment is made (may vary by payment method)
- **Frequency**: Per purchase
- **Contains**: Item description, amount, payment method
---
## ✅ Status: FULLY FUNCTIONAL
**Users can now:**
- ✅ View all their invoices
- ✅ Download invoice PDFs
- ✅ View hosted invoices
- ✅ See invoice status and amounts
- ✅ Access invoices from multiple entry points
**Access Points:**
- `/invoices.php` - Direct access
- `/manage_subscription.php` - "View Invoices" button
- `/account_settings.php?tab=credits` - "View Invoices" button
---
## 🔍 Testing
To test invoice access:
1. Log in as a user with a subscription
2. Navigate to `/invoices.php`
3. Verify invoices are displayed
4. Click "Download PDF" or "View Invoice" to verify links work
5. Check that invoice details are correct
---
## 📝 Notes
- Stripe automatically creates invoices for subscriptions
- Invoices are available immediately after payment
- PDF links are valid for the lifetime of the invoice
- Hosted invoice URLs are also permanent
- Users can access invoices even if subscription is canceled (historical records)