I finally found a solution. I am using the SessionWizardView class in Django 1.4.
I overridden the render_done () function (I copied it directly from django / django / contrib / formtools / wizard / views.py and changed it.
Between 'final_form_list.append (form_obj)' and the last three lines (starting with 'done_response = self.done (final_form_list, ** kwargs)') I process the conversation with the payment gateway.
, ( self.render.revalidation_failure()), .
:
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)
, "3" - , . , , . , , process_step(), , TheRightWay render_done().