diff --git a/registripe/views.py b/registripe/views.py index d5083fa09a78787178faaf836f4b1890027a44c8..8207e2b74f2ce50fa3ff1d7639de7129a686d941 100644 --- a/registripe/views.py +++ b/registripe/views.py @@ -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.