mirror of
https://github.com/thecyberlearn/netcop-ai.git
synced 2026-08-18 07:52:59 +00:00
Features: - Email-based user authentication with token auth - Stripe Checkout integration for wallet top-ups - n8n workflow triggering with automatic fee deduction ($0.10) - Comprehensive transaction and usage logging - Django Admin interface for monitoring - Rate limiting and security middleware - Production-ready deployment configuration - Modular settings (dev/prod environments) - UUID primary keys for enhanced security - Comprehensive test coverage 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
import uuid
|
|
from django.db import models
|
|
from django.conf import settings
|
|
from decimal import Decimal
|
|
|
|
|
|
class WalletTransaction(models.Model):
|
|
TRANSACTION_TYPES = [
|
|
('deposit', 'Deposit'),
|
|
('withdrawal', 'Withdrawal'),
|
|
('fee', 'Fee'),
|
|
]
|
|
|
|
STATUS_CHOICES = [
|
|
('pending', 'Pending'),
|
|
('completed', 'Completed'),
|
|
('failed', 'Failed'),
|
|
]
|
|
|
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='wallet_transactions')
|
|
transaction_type = models.CharField(max_length=20, choices=TRANSACTION_TYPES)
|
|
amount = models.DecimalField(max_digits=10, decimal_places=2)
|
|
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='pending')
|
|
stripe_payment_intent_id = models.CharField(max_length=255, null=True, blank=True)
|
|
description = models.TextField(blank=True)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
class Meta:
|
|
ordering = ['-created_at']
|
|
|
|
def __str__(self):
|
|
return f"{self.user.email} - {self.transaction_type} - ${self.amount}"
|