2026-01-28 16:52:06 +05:30
|
|
|
from django.db import models
|
|
|
|
|
from django.conf import settings
|
|
|
|
|
|
|
|
|
|
User = settings.AUTH_USER_MODEL
|
|
|
|
|
|
|
|
|
|
class RazorpayTransaction(models.Model):
|
|
|
|
|
# Optional: who this transaction relates to
|
|
|
|
|
user = models.ForeignKey(User,
|
|
|
|
|
on_delete=models.SET_NULL,
|
|
|
|
|
null=True, blank=True,
|
|
|
|
|
related_name="razorpay_transactions",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Razorpay identifiers
|
|
|
|
|
razorpay_order_id = models.CharField(max_length=191, unique=True)
|
|
|
|
|
razorpay_payment_id = models.CharField(max_length=191, blank=True, null=True)
|
|
|
|
|
razorpay_signature = models.CharField(max_length=255, blank=True, null=True)
|
|
|
|
|
|
|
|
|
|
# Generic linkage to any domain object (order, booking, wallet topup, etc.)
|
|
|
|
|
reference_type = models.CharField(
|
|
|
|
|
max_length=100,
|
|
|
|
|
blank=True, null=True,
|
|
|
|
|
help_text="What this payment is for, e.g. 'booking', 'wallet_topup', 'ticket'",
|
|
|
|
|
)
|
|
|
|
|
transaction_id = models.CharField(
|
|
|
|
|
max_length=100,
|
|
|
|
|
blank=True, null=True,
|
|
|
|
|
help_text="ID of the related for the transaction",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Amount info (Razorpay uses smallest unit, e.g. paise)
|
|
|
|
|
amount = models.BigIntegerField(help_text="Amount in paise")
|
|
|
|
|
currency = models.CharField(max_length=10, default="INR")
|
|
|
|
|
|
|
|
|
|
# Status & method
|
|
|
|
|
status = models.CharField(
|
|
|
|
|
max_length=50,
|
|
|
|
|
help_text="created/authorized/captured/failed/refunded",
|
feat: Phase 1+2 - JWT auth, dashboard metrics API, DB indexes
Phase 1 - JWT Auth Foundation:
- Replace token auth with djangorestframework-simplejwt
- POST /api/v1/admin/auth/login/ - returns access + refresh JWT
- POST /api/v1/auth/refresh/ - JWT refresh
- GET /api/v1/auth/me/ - current admin profile
- GET /api/v1/health/ - DB health check
- Add ledger app to INSTALLED_APPS
Phase 2 - Dashboard Metrics API:
- GET /api/v1/dashboard/metrics/ - revenue, partners, events, tickets
- GET /api/v1/dashboard/revenue/ - 7-day revenue vs payouts chart data
- GET /api/v1/dashboard/activity/ - last 10 platform events feed
- GET /api/v1/dashboard/actions/ - KYC queue, flagged events, pending payouts
DB Indexes (dashboard query optimisation):
- RazorpayTransaction: status, captured_at
- Partner: status, kyc_compliance_status
- Event: event_status, start_date, created_date
- Booking: created_date
- PaymentTransaction: payment_type, payment_transaction_status, payment_transaction_date
Infra:
- Add Dockerfile for eventify-backend container
- Add simplejwt to requirements.txt
- All 4 dashboard views use IsAuthenticated permission class
2026-03-24 17:46:41 +00:00
|
|
|
db_index=True,
|
2026-01-28 16:52:06 +05:30
|
|
|
)
|
|
|
|
|
method = models.CharField(
|
|
|
|
|
max_length=50,
|
|
|
|
|
blank=True, null=True,
|
|
|
|
|
help_text="card/netbanking/wallet/upi/etc",
|
|
|
|
|
)
|
|
|
|
|
email = models.EmailField(blank=True, null=True)
|
|
|
|
|
contact = models.CharField(max_length=20, blank=True, null=True)
|
|
|
|
|
|
|
|
|
|
# Errors
|
|
|
|
|
error_code = models.CharField(max_length=100, blank=True, null=True)
|
|
|
|
|
error_description = models.TextField(blank=True, null=True)
|
|
|
|
|
|
|
|
|
|
# Extra data
|
|
|
|
|
notes = models.JSONField(blank=True, null=True)
|
|
|
|
|
raw_gateway_response = models.JSONField(
|
|
|
|
|
blank=True, null=True,
|
|
|
|
|
help_text="Full payload from Razorpay",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Timestamps
|
|
|
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
|
|
|
updated_at = models.DateTimeField(auto_now=True)
|
feat: Phase 1+2 - JWT auth, dashboard metrics API, DB indexes
Phase 1 - JWT Auth Foundation:
- Replace token auth with djangorestframework-simplejwt
- POST /api/v1/admin/auth/login/ - returns access + refresh JWT
- POST /api/v1/auth/refresh/ - JWT refresh
- GET /api/v1/auth/me/ - current admin profile
- GET /api/v1/health/ - DB health check
- Add ledger app to INSTALLED_APPS
Phase 2 - Dashboard Metrics API:
- GET /api/v1/dashboard/metrics/ - revenue, partners, events, tickets
- GET /api/v1/dashboard/revenue/ - 7-day revenue vs payouts chart data
- GET /api/v1/dashboard/activity/ - last 10 platform events feed
- GET /api/v1/dashboard/actions/ - KYC queue, flagged events, pending payouts
DB Indexes (dashboard query optimisation):
- RazorpayTransaction: status, captured_at
- Partner: status, kyc_compliance_status
- Event: event_status, start_date, created_date
- Booking: created_date
- PaymentTransaction: payment_type, payment_transaction_status, payment_transaction_date
Infra:
- Add Dockerfile for eventify-backend container
- Add simplejwt to requirements.txt
- All 4 dashboard views use IsAuthenticated permission class
2026-03-24 17:46:41 +00:00
|
|
|
captured_at = models.DateTimeField(blank=True, null=True, db_index=True)
|
2026-01-28 16:52:06 +05:30
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return f"{self.razorpay_payment_id or self.razorpay_order_id} - {self.status}"
|
|
|
|
|
|
|
|
|
|
def __save__(self):
|
|
|
|
|
if not self.transaction_id:
|
|
|
|
|
self.transaction_id = str(uuid.uuid4().hex[:10]).upper()
|
|
|
|
|
super().save(*args, **kwargs)
|