Changeset - 67b047e7b30e
[Not reviewed]
0 1 0
Christopher Neugebauer - 8 years ago 2016-04-24 21:20:41
chrisjrn@gmail.com
Simplifies invoice-getting documentation.
1 file changed with 1 insertions and 4 deletions:
0 comments (0 inline, 0 general)
docs/payments.rst
Show inline comments
...
 
@@ -23,28 +23,25 @@ Making payments is a three-step process:
 

	
 
Pre-validation
 
~~~~~~~~~~~~~~
 
Registrasion's ``InvoiceController`` has a ``validate_allowed_to_pay`` method, which performs all of the pre-payment checks (is the invoice still unpaid and non-void? has the registration been amended?).
 

	
 
If the pre-payment check fails, ``InvoiceController`` will raise a Django ``ValidationError``.
 

	
 
Our the ``demopay`` view from the ``registrasion-demo`` project implements pre-validation like so::
 

	
 
    from registrasion.controllers.invoice import InvoiceController
 
    from django.core.exceptions import ValidationError
 

	
 
    # Get the Registrasion Invoice model
 
    inv = get_object_or_404(rego.Invoice.objects, pk=invoice_id)
 

	
 
    invoice = InvoiceController(inv)
 
    invoice = InvoiceController.for_id_or_404(invoice.id)
 

	
 
    try:
 
        invoice.validate_allowed_to_pay()  # Verify that we're allowed to do this.
 
    except ValidationError as ve:
 
        messages.error(request, ve.message)
 
        return REDIRECT_TO_INVOICE  # And display the validation message.
 

	
 
In most cases, you don't engage your actual payment application until after pre-validation is finished, as this gives you an opportunity to bail out if the invoice isn't able to have funds applied to it.
 

	
 
Applying payments
 
~~~~~~~~~~~~~~~~~
 
Payments in Registrasion are represented as subclasses of the ``PaymentBase`` model. ``PaymentBase`` looks like this:
0 comments (0 inline, 0 general)