JourneyJoker/payment/sepa/models.py

24 lines
709 B
Python

from payment.models import InvoicePayment, Invoice
from django.db import models
import random
import string
from .functions import generate_reference
class SepaPaymentReference(models.Model):
invoice = models.ForeignKey(Invoice, models.CASCADE)
reference = models.IntegerField(default=generate_reference)
def create_payment(self, amount):
return SepaInvoicePayment.objects.create(invoice=self.invoice, gateway_id=self.reference, amount=amount)
class SepaInvoicePayment(InvoicePayment):
@property
def gateway(self):
return "Bank Transfer"
@staticmethod
def initiate(subscription):
SepaPaymentReference.objects.get_or_create(subscription=subscription)