2.5 KiB
2.5 KiB
PAYMENT APPROVAL - ADMIN QUICK GUIDE
How It Works Now (FIXED)
When User Submits Payment Confirmation:
- Payment record created with status:
pending_approval - Invoice status:
pending - Account status:
pending_payment - Credits: 0
When You Approve Payment (AUTOMATIC CASCADE):
Option 1: Change Status in Admin
- Open Payment in Django Admin
- Change Status dropdown:
pending_approval→succeeded - Click Save
- ✅ EVERYTHING UPDATES AUTOMATICALLY:
- Payment status →
succeeded - Invoice status →
paid - Subscription status →
active - Account status →
active - Credits added (e.g., 5,000 for Starter plan)
- Payment status →
Option 2: Bulk Approve
- Go to Payments list in Django Admin
- Select payments with status
pending_approval - Actions dropdown: "Approve selected manual payments"
- Click Go
- ✅ ALL SELECTED PAYMENTS PROCESSED AUTOMATICALLY
Simplified Payment Statuses (Only 4)
| Status | Meaning | What To Do |
|---|---|---|
pending_approval |
User submitted payment, waiting for you | Verify & approve or reject |
succeeded |
Approved & account activated | Nothing - done! |
failed |
Rejected or failed | User needs to retry |
refunded |
Money returned | Rare case |
REMOVED unnecessary statuses: pending, processing, completed, cancelled
What Happens Automatically When Status → succeeded:
Payment.save() override does this:
├─ 1. Invoice.status = 'paid'
├─ 2. Invoice.paid_at = now
├─ 3. Subscription.status = 'active'
├─ 4. Subscription.external_payment_id = manual_reference
├─ 5. Account.status = 'active'
└─ 6. CreditService.add_credits(plan.included_credits)
That's It!
You only change ONE thing: Payment status to succeeded
Everything else is automatic. No need to:
- ❌ Manually update invoice
- ❌ Manually update account
- ❌ Manually add credits
- ❌ Manually activate subscription
Files Changed:
-
/backend/igny8_core/business/billing/models.py- Payment.STATUS_CHOICES: 8 → 4 statuses
- Payment.save() override: auto-cascade on approval
-
/backend/igny8_core/modules/billing/admin.py- PaymentAdmin.save_model(): sets approved_by
- Bulk actions work correctly
-
/backend/igny8_core/business/billing/admin.py- Duplicate PaymentAdmin disabled
Migration:
Run: python manage.py migrate
This will:
- Map old statuses (pending, processing, completed, cancelled) to new ones
- Update database constraints