Documentation, and edge case.

This commit is contained in:
Christopher Neugebauer 2016-09-22 09:38:22 +10:00
parent cbf3f5814b
commit 6c87b9d08a

View file

@ -30,6 +30,13 @@ def pubkey_script(request):
def card(request, invoice_id):
''' View that shows and processes a Stripe CreditCardForm to pay the given
invoice. Redirects back to the invoice once the invoice is fully paid.
Arguments:
invoice_id (castable to str): The invoice id for the invoice to pay.
'''
form = forms.CreditCardForm(request.POST or None)
@ -40,6 +47,9 @@ def card(request, invoice_id):
to_invoice = redirect("invoice", inv.invoice.id)
if inv.invoice.balance_due() <= 0:
return to_invoice
if request.POST and form.is_valid():
try:
inv.validate_allowed_to_pay() # Verify that we're allowed to do this.