def validate_payment_form(self): payment_form = self.payment_form_class(self.request.POST) billing_form = self.billing_form_class(self.request.POST) if self.shipping_form_class: shipping_form = self.shipping_form_class(self.request.POST) #if shipping for exists also validate it if payment_form.is_valid() and billing_form.is_valid() and (not self.shipping_form_class or shipping_form.is_valid()): if not self.shipping_form_class: args = payment_form, billing_form else: args = payment_form, billing_form, shipping_form form_data = combine_form_data(*args) response = process_payment(form_data, self.extra_data) self.context['response'] = response if response.is_approved: return direct_to_template(self.request, self.success_template, self.context) else: self.context['errors'] = self.processing_error self.context['payment_form'] = payment_form self.context['billing_form'] = billing_form if self.shipping_form_class: self.context['shipping_form'] = shipping_form self.context.setdefault('errors', self.form_error) return direct_to_template(self.request, self.payment_template, self.context)
def validate_payment_form(self): payment_form = self.payment_form_class(self.request.POST) billing_form = self.billing_form_class(self.request.POST) if self.shipping_form_class: shipping_form = self.shipping_form_class(self.request.POST) #if shipping for exists also validate it if payment_form.is_valid() and billing_form.is_valid() and ( not self.shipping_form_class or shipping_form.is_valid()): if not self.shipping_form_class: args = payment_form, billing_form else: args = payment_form, billing_form, shipping_form form_data = combine_form_data(*args) response = process_payment(form_data, self.extra_data) self.context['response'] = response if response.is_approved: return direct_to_template(self.request, self.success_template, self.context) else: self.context['errors'] = self.processing_error self.context['payment_form'] = payment_form self.context['billing_form'] = billing_form if self.shipping_form_class: self.context['shipping_form'] = shipping_form self.context.setdefault('errors', self.form_error) return direct_to_template(self.request, self.payment_template, self.context)
def validate_payment_form(self): payment_form = self.payment_form_class(self.request.POST) billing_form = self.billing_form_class(self.request.POST) if payment_form.is_valid() and billing_form.is_valid(): form_data = combine_form_data(payment_form, billing_form) response = process_payment(form_data, self.extra_data) self.context['response'] = response if response.is_approved: return direct_to_template(self.request, self.success_template, self.context) else: self.context['errors'] = self.processing_error self.context['payment_form'] = payment_form self.context['billing_form'] = billing_form self.context.setdefault('errors', self.form_error) return direct_to_template(self.request, self.payment_template, self.context)
def validate_payment_form(self): payment_form = self.payment_form_class(self.request.POST) billing_form = self.billing_form_class(self.request.POST) if payment_form.is_valid() and billing_form.is_valid(): from authorizenet.utils import process_payment, combine_form_data form_data = combine_form_data(payment_form, billing_form) response = process_payment(form_data, self.extra_data) self.context["response"] = response if response.is_approved: return render_to_response( self.success_template, self.context, context_instance=RequestContext(self.request) ) else: self.context["errors"] = self.processing_error self.context["payment_form"] = payment_form self.context["billing_form"] = billing_form self.context.setdefault("errors", self.form_error) return render_to_response(self.payment_template, self.context, context_instance=RequestContext(self.request))