2018-06-21 18:03:46 +00:00
|
|
|
from django.db import models
|
|
|
|
from django.shortcuts import render
|
|
|
|
|
2018-07-02 19:13:13 +00:00
|
|
|
from cotisations.models import Paiement
|
|
|
|
from cotisations.payment_methods.mixins import PaymentMethodMixin
|
2018-06-21 18:03:46 +00:00
|
|
|
|
|
|
|
from .aes_field import AESEncryptedField
|
|
|
|
from .views import comnpay
|
|
|
|
|
|
|
|
|
2018-07-02 19:13:13 +00:00
|
|
|
class ComnpayPayment(PaymentMethodMixin, models.Model):
|
2018-06-21 18:03:46 +00:00
|
|
|
"""
|
2018-07-02 19:13:13 +00:00
|
|
|
The model allowing you to pay with COMNPAY.
|
2018-06-21 18:03:46 +00:00
|
|
|
"""
|
2018-07-02 19:13:13 +00:00
|
|
|
payment = models.OneToOneField(
|
|
|
|
Paiement,
|
|
|
|
related_name='payment_method',
|
|
|
|
editable=False
|
|
|
|
)
|
2018-06-21 18:03:46 +00:00
|
|
|
payment_credential = models.CharField(
|
|
|
|
max_length=255,
|
|
|
|
default='',
|
|
|
|
blank=True
|
|
|
|
)
|
|
|
|
payment_pass = AESEncryptedField(
|
|
|
|
max_length=255,
|
|
|
|
null=True,
|
|
|
|
blank=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
def end_payment(self, invoice, request):
|
2018-07-02 13:01:34 +00:00
|
|
|
invoice.valid = False
|
|
|
|
invoice.save()
|
2018-07-02 20:14:51 +00:00
|
|
|
content = comnpay(invoice, request, self)
|
2018-06-21 18:03:46 +00:00
|
|
|
return render(request, 'cotisations/payment.html', content)
|