Adds dumb process for paying invoices.

This commit is contained in:
Christopher Neugebauer 2016-03-23 14:51:04 +11:00
parent 4dc150d734
commit e118a4e74c
2 changed files with 16 additions and 0 deletions

View file

@ -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"),
)

View file

@ -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)