JourneyJoker/payment/sepa/views.py
Klaus-Uwe Mitterer 54e84be36a Implement login system
Copy over payment system from kumi.xxx
Add missing requirements
Other stuff
2021-03-21 16:50:50 +01:00

23 lines
No EOL
789 B
Python

from django.views.generic import FormView
from django.shortcuts import get_object_or_404
from django.contrib import messages
from localauth.mixins import SuperUserRequiredMixin
from .forms import SepaApplyPaymentForm
from .models import SepaPaymentReference, SepaInvoicePayment
class SepaApplyPaymentView(SuperUserRequiredMixin, FormView):
form_class = SepaApplyPaymentForm
success_url = '/'
def form_valid(self, form):
reference = form.cleaned_data["reference"]
pr = get_object_or_404(SepaPaymentReference, reference=reference)
invoice = pr.invoice
SepaInvoicePayment.objects.create(invoice=invoice, amount=form.cleaned_data["amount"])
messages.success(self.request, "Zahlung angewendet.")
return super().form_valid(form)