inital commit

This commit is contained in:
2026-04-10 20:51:43 -05:00
parent cd1f2eae29
commit 562a8525d0
85 changed files with 4820 additions and 2 deletions

40
payment/models.py Normal file
View File

@@ -0,0 +1,40 @@
from django.db import models
class PaymentRecord(models.Model):
class Status(models.TextChoices):
REQUIRES_PAYMENT = "requires_payment", "Requires Payment"
PROCESSING = "processing", "Processing"
SUCCEEDED = "succeeded", "Succeeded"
FAILED = "failed", "Failed"
REFUNDED = "refunded", "Refunded"
booking = models.ForeignKey("booking.Booking", on_delete=models.CASCADE, related_name="payments")
stripe_payment_intent_id = models.CharField(max_length=255, unique=True)
stripe_charge_id = models.CharField(max_length=255, blank=True)
amount = models.DecimalField(max_digits=10, decimal_places=2)
currency = models.CharField(max_length=8, default="usd")
status = models.CharField(max_length=32, choices=Status.choices, default=Status.REQUIRES_PAYMENT)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
ordering = ("-created_at",)
def __str__(self) -> str:
return f"Payment {self.stripe_payment_intent_id} ({self.status})"
class WebhookEvent(models.Model):
stripe_event_id = models.CharField(max_length=255, unique=True)
event_type = models.CharField(max_length=120)
payload = models.JSONField(default=dict)
processed = models.BooleanField(default=False)
processed_at = models.DateTimeField(null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
ordering = ("-created_at",)
def __str__(self) -> str:
return f"{self.event_type} ({self.stripe_event_id})"