from django.db import models from django.conf import settings class PaymentOrder(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.DO_NOTHING) credits = models.IntegerField() # Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. currency = models.CharField(max_length=3) unit_price = models.DecimalField(max_digits=10, decimal_places=2) paid_amount = models.DecimalField(max_digits=10, decimal_places=2) paid_at = models.DateTimeField(null=True, blank=True) provider_order_number = models.CharField( max_length=100, null=True, blank=True, unique=True, help_text="The order number from the payment provider", ) transaction = models.ForeignKey( "labs.CreditTransaction", on_delete=models.DO_NOTHING, null=True, blank=True, help_text="The transaction id of the payment order", ) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) class Meta: db_table = "billing_payment_orders"