forked from data.coop/membersystem
WIP: Changes to payment models
This commit is contained in:
parent
d31f62ebb4
commit
7cc22aa0a1
|
@ -1,5 +1,5 @@
|
||||||
default_language_version:
|
default_language_version:
|
||||||
python: python3.12
|
python: python3
|
||||||
exclude: ^.*\b(migrations)\b.*$
|
exclude: ^.*\b(migrations)\b.*$
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- 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"))
|
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
|
@property
|
||||||
def display_id(self):
|
def display_id(self):
|
||||||
return str(self.id).zfill(6)
|
return str(self.id).zfill(6)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_order(cls, order):
|
def from_order(cls, order, payment_type):
|
||||||
return cls.objects.create(
|
return cls.objects.create(
|
||||||
order=order,
|
order=order,
|
||||||
user=order.user,
|
user=order.user,
|
||||||
amount=order.total,
|
amount=order.total,
|
||||||
description=order.description,
|
description=order.description,
|
||||||
|
payment_type=payment_type,
|
||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
|
@ -119,3 +123,18 @@ class Payment(CreatedModifiedAbstract):
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("payment")
|
verbose_name = _("payment")
|
||||||
verbose_name_plural = _("payments")
|
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