From e118a4e74c8cec8d06637b7dab14344e190b2f5d Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Wed, 23 Mar 2016 14:51:04 +1100 Subject: [PATCH] Adds dumb process for paying invoices. --- registrasion/urls.py | 1 + registrasion/views.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/registrasion/urls.py b/registrasion/urls.py index d8a1c6db..746d163d 100644 --- a/registrasion/urls.py +++ b/registrasion/urls.py @@ -5,4 +5,5 @@ urlpatterns = patterns( url(r"^category/([0-9]+)$", "product_category", name="product_category"), url(r"^checkout$", "checkout", name="checkout"), url(r"^invoice/([0-9]+)$", "invoice", name="invoice"), + url(r"^invoice/([0-9]+)/pay$", "pay_invoice", name="pay_invoice"), ) diff --git a/registrasion/views.py b/registrasion/views.py index 075cd2e7..3957da7d 100644 --- a/registrasion/views.py +++ b/registrasion/views.py @@ -118,3 +118,18 @@ def invoice(request, invoice_id): } return render(request, "invoice.html", data) + +@login_required +def pay_invoice(request, invoice_id): + ''' Marks the invoice with the given invoice id as paid. + WORK IN PROGRESS FUNCTION. Must be replaced with real payment workflow. + + ''' + + invoice_id = int(invoice_id) + inv = rego.Invoice.objects.get(pk=invoice_id) + current_invoice = InvoiceController(inv) + if not inv.paid and not current_invoice.is_valid(): + current_invoice.pay("Demo invoice payment", inv.value) + + return redirect("invoice", current_invoice.invoice.id)