4.8 KiB
4.8 KiB
Payment Registration System - Summary
Overview
A complete payment registration system for your course platform that allows guardians/students to register payments and enables admins to track payment status.
What You'll Get
1. Database Model
- New
Paymentmodel with fields:classId- Reference to the classuserId- Reference to the user (guardian/student)amount- Payment valuepaymentDate- Date and time of paymentpaymentMethod- Method (PIX, bank transfer, cash, etc.)status- Pending, Verified, or RejectedreceiptUrl- Optional receipt imagenotes- Optional notes
2. API Routes
/api/payments- Create and list payments/api/payments/[id]- Get, update, delete single payment/api/payments/class/[classId]- Get all payments for a class/api/payments/user/[userId]- Get all payments for a user
3. Admin Dashboard
/admin/dashboard/payments- Main dashboard- Features:
- View all payments in a table
- Filter by status (all, pending, verified, rejected)
- See payment statistics (total, verified, pending, rejected)
- Verify or reject payments
- View payment details
4. Guardian/Student Interface
- Payment Registration:
- Form to register payments with amount, date, method
- Optional receipt image upload
- Notes field for additional information
- Payment History:
- View all registered payments
- See payment status for each class
5. Payment Status Indicators
- Reusable
PaymentStatusBadgecomponent - Shows status: Not Paid, Pending, Paid, or Rejected
- Color-coded badges for easy identification
How It Works
For Guardians/Students:
- Navigate to a class they're enrolled in or their ward is enrolled in
- Click "Registrar Pagamento" (Register Payment)
- Fill in payment details:
- Amount (R$)
- Payment date
- Payment method (PIX, bank transfer, cash, etc.)
- Optional: Upload receipt image
- Optional: Add notes
- Submit the form
- Payment status becomes "Pending" (waiting for admin verification)
For Admins:
- Navigate to Admin Dashboard → Payments
- View all payments in a table
- See payment statistics at the top
- Filter payments by status
- Click on a payment to see details
- Verify or reject the payment
- Payment status updates accordingly
File Structure
src/
├── app/
│ ├── api/payments/ # API routes
│ ├── (protected)/
│ │ ├── admin/dashboard/payments/ # Admin dashboard
│ │ ├── dashboard/guardian/payments/ # Guardian interface
│ │ └── dashboard/student/payments/ # Student interface
│ └── components/shared/PaymentStatusBadge.jsx # Reusable component
├── models/Payment.js # Payment model
└── lib/utils/payments.js # Helper functions
Security Features
- Role-Based Access Control:
- Only admins can view payment details
- Guardians can only register payments for their wards
- Students can only register payments for their enrolled classes
- Data Validation:
- Amount must be positive
- Payment date must be valid
- File uploads are validated
- Data Integrity:
- All payments are tracked with timestamps
- Payment status workflow is enforced
Integration with Existing System
- Uses existing file upload infrastructure
- Integrates with existing User and Class models
- Follows existing API patterns
- Uses existing UI components
- Compatible with current role-based authentication
Next Steps
-
Review the plans:
payment-system-architecture.md- High-level architecturepayment-system-implementation.md- Detailed implementation guide
-
Implementation order:
- Create Payment model
- Create API routes
- Create admin dashboard
- Create guardian/student interface
- Integrate with class views
- Test the complete flow
-
Testing checklist:
- Create payment with guardian account
- Verify payment with admin account
- Test file upload for receipts
- Verify role-based access control
- Test payment status indicators
Questions?
The detailed implementation guide includes:
- Complete code for all components
- API route implementations
- Database schema definitions
- UI component code
- Integration points
- Testing checklist
Would you like me to proceed with implementing this system? I can start by creating the Payment model and API routes.