2021-03-21 15:50:50 +00:00
|
|
|
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)
|
|
|
|
|
2021-03-22 17:42:07 +00:00
|
|
|
def create_payment(self, amount):
|
|
|
|
return SepaInvoicePayment.objects.create(invoice=self.invoice, gateway_id=self.reference, amount=amount)
|
|
|
|
|
2021-03-21 15:50:50 +00:00
|
|
|
class SepaInvoicePayment(InvoicePayment):
|
|
|
|
@property
|
|
|
|
def gateway(self):
|
|
|
|
return "Bank Transfer"
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def initiate(subscription):
|
|
|
|
SepaPaymentReference.objects.get_or_create(subscription=subscription)
|