Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I finally hit upon a solution. I'm using the SessionWizardView class in Django 1.4.</p> <p>I overrode the render_done() function (copied it directly out of django/django/contrib/formtools/wizard/views.py and tweaked it.</p> <p>Between 'final_form_list.append(form_obj)' and the last three lines (starting with 'done_response = self.done(final_form_list, **kwargs)') I handle talking with the payment gateway.</p> <p>If there's an error, I redirect back to the last step in the form (using self.render.revalidation_failure()) and they can try again.</p> <p>Here's a snippet of code:</p> <pre><code>try: charge = stripe.Charge.create( amount=price_in_cents, currency="usd", card=token, description="BlahStore Order Number: %s" %(self.order.pk), ) except (stripe.APIConnectionError, stripe.APIError, stripe.AuthenticationError, stripe.CardError, stripe.InvalidRequestError, stripe.StripeError) as e: from django.forms import forms from django.forms.util import ErrorList errors = final_form_list[3]._errors.setdefault(forms.NON_FIELD_ERRORS, ErrorList()) errors.append(e.message) return self.render_revalidation_failure(3, final_form_list[3], **kwargs) </code></pre> <p>You'll notice I have '3' hard-coded in a few places--this is because my wizard has four steps and the array is zero based. I set the error message to display and then redirect. I'm sure it would be fairly easy to adapt this if you wanted to stick with process_step(), but I personally think TheRightWay is to override the render_done() function.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload