WIP: Changes to payment models
This commit is contained in:
parent
d31f62ebb4
commit
7cc22aa0a1
|
@ -1,5 +1,5 @@
|
|||
default_language_version:
|
||||
python: python3.12
|
||||
python: python3
|
||||
exclude: ^.*\b(migrations)\b.*$
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
|
|
|
@ -98,19 +98,23 @@ class Payment(CreatedModifiedAbstract):
|
|||
|
||||
description = models.CharField(max_length=1024, verbose_name=_("description"))
|
||||
|
||||
stripe_charge_id = models.CharField(max_length=255, null=True, blank=True)
|
||||
payment_type = models.ForeignKey("PaymentType", on_delete=models.PROTECT)
|
||||
external_transaction_id = models.CharField(max_length=255, null=True, blank=True)
|
||||
|
||||
# stripe_charge_id = models.CharField(max_length=255, null=True, blank=True)
|
||||
|
||||
@property
|
||||
def display_id(self):
|
||||
return str(self.id).zfill(6)
|
||||
|
||||
@classmethod
|
||||
def from_order(cls, order):
|
||||
def from_order(cls, order, payment_type):
|
||||
return cls.objects.create(
|
||||
order=order,
|
||||
user=order.user,
|
||||
amount=order.total,
|
||||
description=order.description,
|
||||
payment_type=payment_type,
|
||||
)
|
||||
|
||||
def __str__(self) -> str:
|
||||
|
@ -119,3 +123,18 @@ class Payment(CreatedModifiedAbstract):
|
|||
class Meta:
|
||||
verbose_name = _("payment")
|
||||
verbose_name_plural = _("payments")
|
||||
|
||||
|
||||
class PaymentType(CreatedModifiedAbstract):
|
||||
"""Types of payments available in the system:
|
||||
- bank transfer
|
||||
- card payment (specific provider)
|
||||
"""
|
||||
|
||||
name = models.CharField(max_length=1024, verbose_name=_("description"))
|
||||
description = models.TextField(max_length=2048, null=True, blank=True)
|
||||
|
||||
enabled = models.BooleanField(default=True)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.name}"
|
||||
|
|
Loading…
Reference in a new issue