@@ -27,22 +27,32 @@ def pubkey_script(request):
script = script_template % settings.PINAX_STRIPE_PUBLIC_KEY
return HttpResponse(script, content_type="text/javascript")
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)
inv = InvoiceController.for_id_or_404(str(invoice_id))
if not inv.can_view(user=request.user):
raise Http404()
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.
process_card(request, form, inv)
except StripeError as e: