示例#1
0
    def handle_place_order_submission(self, request):
        paypal_form = PaymentForm(request.POST)
        bankcard_form = BankcardForm(request.POST)
        #shipping_address = self.get_shipping_address(
        #    self.request.basket)
        #print request.POST
        #address_form = BillingAddressForm(shipping_address, request.POST)
        #print 'handling order submision'
        #print address_form.is_valid()
        #print address_form.__dict__

        #a = bankcard_form.is_valid()
        #print a
        if paypal_form.is_valid() and bankcard_form.is_valid(): #address_form.is_valid() and bankcard_form.is_valid():
            # Forms still valid, let's submit an order
            submission = self.build_submission(
                #order_kwargs={
                #    'billing_address': address_form.save(commit=False),
                #},
                payment_kwargs={
                    'bankcard_form': bankcard_form,
                    'paypal_form' : paypal_form,
                    #'billing_address_form': address_form
                }
            )
            print 'about to submit'
            return self.submit(**submission)
        # Must be DOM tampering as these forms were valid and were rendered in
        # a hidden element.  Hence, we don't need to be that friendly with our
        # error message.
        print 'invalid submision'
        messages.error(request, _("Invalid submission"))
        return http.HttpResponseRedirect(
            reverse('checkout:payment-details'))
示例#2
0
    def handle_payment_details_submission(self, request):
        # Check bankcard form is valid
        bankcard_form = BankcardForm(request.POST)
        if bankcard_form.is_valid():
            return self.render_preview(request, bankcard_form=bankcard_form)

        # Form invalid - re-render
        return self.render_payment_details(request,
                                           bankcard_form=bankcard_form)
示例#3
0
    def handle_place_order_submission(self, request):
        bankcard_form = BankcardForm(request.POST)
        if bankcard_form.is_valid():
            submission = self.build_submission(
                payment_kwargs={'bankcard_form': bankcard_form})
            return self.submit(**submission)

        messages.error(request, _("Invalid submission"))
        return http.HttpResponseRedirect(reverse('checkout:payment-details'))
示例#4
0
    def handle_payment_details_submission(self, request):
        # Check bankcard form is valid
        bankcard_form = BankcardForm(request.POST)
        if bankcard_form.is_valid():
            return self.render_preview(
                request, bankcard_form=bankcard_form)

        # Form invalid - re-render
        return self.render_payment_details(
            request, bankcard_form=bankcard_form)
示例#5
0
 def handle_POST(self):
     if self.is_cheque_payment():
         return self.submit()
     try:    
         self.bankcard_form = BankcardForm(self.request.POST)
         self.billing_addr_form = BillingAddressForm(self.request.POST)
         if self.bankcard_form.is_valid() and self.billing_addr_form.is_valid():
             return self.submit()
     except TransactionDeclinedException, e:
         self.context['payment_error'] = str(e)
    def do_place_order(self, request):
        bankcard_form = BankcardForm(request.POST)
        if not bankcard_form.is_valid():
            messages.error(request, _("Invalid submission"))
            return HttpResponseRedirect(reverse('checkout:payment-details'))
        bankcard = bankcard_form.get_bankcard_obj()

        # Call oscar's submit method, passing through the bankcard object so it
        # gets passed to the 'handle_payment' method
        return self.submit(request.basket,
                           payment_kwargs={'bankcard': bankcard})
示例#7
0
    def do_place_order(self, request):
        bankcard_form = BankcardForm(request.POST)
        if not bankcard_form.is_valid():
            messages.error(request, _("Invalid submission"))
            return HttpResponseRedirect(reverse('checkout:payment-details'))
        bankcard = bankcard_form.get_bankcard_obj()

        # Call oscar's submit method, passing through the bankcard object so it
        # gets passed to the 'handle_payment' method
        return self.submit(request.basket,
                           payment_kwargs={'bankcard': bankcard})
示例#8
0
    def do_place_order(self, request):
        # Double-check the bankcard data is still valid
        bankcard_form = BankcardForm(request.POST)
        if not bankcard_form.is_valid():
            # Must be tampering - we don't need to be that friendly with our
            # error message.
            messages.error(request, _("Invalid submission"))
            return http.HttpResponseRedirect(
                reverse('checkout:payment-details'))

        submission = self.build_submission(bankcard_form)
        return self.submit(**submission)
示例#9
0
    def handle_place_order_submission(self, request):
        bankcard_form = BankcardForm(request.POST)
        if bankcard_form.is_valid():
            submission = self.build_submission(
                payment_kwargs={
                    'bankcard_form': bankcard_form
                })
            return self.submit(**submission)

        messages.error(request, _("Invalid submission"))
        return http.HttpResponseRedirect(
            reverse('checkout:payment-details'))
示例#10
0
    def do_place_order(self, request):
        # Double-check the bankcard data is still valid
        bankcard_form = BankcardForm(request.POST)
        if not bankcard_form.is_valid():
            # Must be tampering - we don't need to be that friendly with our
            # error message.
            messages.error(request, _("Invalid submission"))
            return http.HttpResponseRedirect(
                reverse('checkout:payment-details'))

        submission = self.build_submission(bankcard_form)
        return self.submit(**submission)
示例#11
0
    def post(self, request, *args, **kwargs):
        if request.POST.get('action', '') == 'place_order':
            return self.do_place_order(request)

        # Check bankcard form is valid
        bankcard_form = BankcardForm(request.POST)
        if not bankcard_form.is_valid():
            ctx = self.get_context_data(**kwargs)
            ctx['bankcard_form'] = bankcard_form
            return self.render_to_response(ctx)

        # Render preview page (with bankcard details hidden)
        return self.render_preview(request, bankcard_form=bankcard_form)
    def post(self, request, *args, **kwargs):
        if request.POST.get('action', '') == 'place_order':
            return self.do_place_order(request)

        # Check bankcard form is valid
        bankcard_form = BankcardForm(request.POST)
        if not bankcard_form.is_valid():
            ctx = self.get_context_data(**kwargs)
            ctx['bankcard_form'] = bankcard_form
            return self.render_to_response(ctx)

        # Render preview page (with bankcard details hidden)
        return self.render_preview(request, bankcard_form=bankcard_form)
示例#13
0
    def do_place_order(self, request):
        # Double-check the bankcard data is still valid
        bankcard_form = BankcardForm(request.POST)
        if not bankcard_form.is_valid():
            messages.error(request, _("Invalid submission"))
            return http.HttpResponseRedirect(
                reverse('checkout:payment-details'))

        # Call oscar's submit method, passing through the bankcard object so it
        # gets passed to the 'handle_payment' method and can be used for the
        # submission to Datacash.
        bankcard = bankcard_form.bankcard
        return self.submit(request.basket,
                           payment_kwargs={'bankcard': bankcard})
示例#14
0
    def do_place_order(self, request):
        # Double-check the bankcard data is still valid
        bankcard_form = BankcardForm(request.POST)
        if not bankcard_form.is_valid():
            messages.error(request, _("Invalid submission"))
            return http.HttpResponseRedirect(
                reverse('checkout:payment-details'))

        # Call oscar's submit method, passing through the bankcard object so it
        # gets passed to the 'handle_payment' method and can be used for the
        # submission to Datacash.
        bankcard = bankcard_form.bankcard
        return self.submit(request.basket,
                           payment_kwargs={'bankcard': bankcard})
示例#15
0
class PaymentDetailsView(CorePaymentDetailsView):
    template_file = 'checkout/payment_details.html'
    
    def handle_GET(self):
        if self.is_cheque_payment():
            self.template_file = 'checkout/payment_details_cheque.html'
        else:
            shipping_addr = self.get_shipping_address()
            card_values = {'name': shipping_addr.name()}
            self.context['bankcard_form'] = BankcardForm(initial=card_values)
            addr_values = {'first_name': shipping_addr.first_name,
                           'last_name': shipping_addr.last_name,}
            self.context['billing_address_form'] = BillingAddressForm(initial=addr_values)
        return TemplateResponse(self.request, self.template_file, self.context)
    
    def handle_POST(self):
        if self.is_cheque_payment():
            return self.submit()
        try:    
            self.bankcard_form = BankcardForm(self.request.POST)
            self.billing_addr_form = BillingAddressForm(self.request.POST)
            if self.bankcard_form.is_valid() and self.billing_addr_form.is_valid():
                return self.submit()
        except TransactionDeclinedException, e:
            self.context['payment_error'] = str(e)
        
        self.context['bankcard_form'] = self.bankcard_form
        self.context['billing_address_form'] = self.billing_addr_form
        return TemplateResponse(self.request, self.template_file, self.context)
示例#16
0
class PaymentDetailsView(CorePaymentDetailsView):
    template_file = "checkout/payment_details.html"

    def handle_GET(self):
        if self.is_cheque_payment():
            self.template_file = "checkout/payment_details_cheque.html"
        else:
            shipping_addr = self.get_shipping_address()
            card_values = {"name": shipping_addr.name()}
            self.context["bankcard_form"] = BankcardForm(initial=card_values)
            addr_values = {"first_name": shipping_addr.first_name, "last_name": shipping_addr.last_name}
            self.context["billing_address_form"] = BillingAddressForm(initial=addr_values)
        return TemplateResponse(self.request, self.template_file, self.context)

    def handle_POST(self):
        if self.is_cheque_payment():
            return self.submit()
        try:
            self.bankcard_form = BankcardForm(self.request.POST)
            self.billing_addr_form = BillingAddressForm(self.request.POST)
            if self.bankcard_form.is_valid() and self.billing_addr_form.is_valid():
                return self.submit()
        except TransactionDeclinedException, e:
            self.context["payment_error"] = str(e)

        self.context["bankcard_form"] = self.bankcard_form
        self.context["billing_address_form"] = self.billing_addr_form
        return TemplateResponse(self.request, self.template_file, self.context)
示例#17
0
    def post(self, request, *args, **kwargs):
        if request.POST.get('action', '') == 'place_order':
            return self.do_place_order(request)

        # Check bankcard form is valid
        bankcard_form = BankcardForm(request.POST)
        if not bankcard_form.is_valid():
            # Bancard form invalid, re-render the payment details template
            self.preview = False
            ctx = self.get_context_data(**kwargs)
            ctx['bankcard_form'] = bankcard_form
            return self.render_to_response(ctx)

        # Render preview page (with completed bankcard form hidden).
        # Note, we don't write the bankcard details to the session or DB
        # as a security precaution.
        return self.render_preview(request, bankcard_form=bankcard_form)
示例#18
0
    def post(self, request, *args, **kwargs):
        if request.POST.get('action', '') == 'place_order':
            return self.do_place_order(request)

        # Check bankcard form is valid
        bankcard_form = BankcardForm(request.POST)
        if not bankcard_form.is_valid():
            # Bancard form invalid, re-render the payment details template
            self.preview = False
            ctx = self.get_context_data(**kwargs)
            ctx['bankcard_form'] = bankcard_form
            return self.render_to_response(ctx)

        # Render preview page (with completed bankcard form hidden).
        # Note, we don't write the bankcard details to the session or DB
        # as a security precaution.
        return self.render_preview(request, bankcard_form=bankcard_form)
示例#19
0
 def handle_POST(self):
     if self.is_cheque_payment():
         return self.submit()
     try:
         self.bankcard_form = BankcardForm(self.request.POST)
         self.billing_addr_form = BillingAddressForm(self.request.POST)
         if self.bankcard_form.is_valid() and self.billing_addr_form.is_valid():
             return self.submit()
     except TransactionDeclinedException, e:
         self.context["payment_error"] = str(e)
示例#20
0
 def handle_GET(self):
     if self.is_cheque_payment():
         self.template_file = 'checkout/payment_details_cheque.html'
     else:
         shipping_addr = self.get_shipping_address()
         card_values = {'name': shipping_addr.name()}
         self.context['bankcard_form'] = BankcardForm(initial=card_values)
         addr_values = {'first_name': shipping_addr.first_name,
                        'last_name': shipping_addr.last_name,}
         self.context['billing_address_form'] = BillingAddressForm(initial=addr_values)
     return TemplateResponse(self.request, self.template_file, self.context)
示例#21
0
    def post(self, request, *args, **kwargs):
        bankcard_form = BankcardForm(request.POST)

        if request.POST.get('action', '') == 'place_order':
            if not bankcard_form.is_valid():
                messages.error(request, _("Invalid submission"))
                return HttpResponseRedirect(
                    reverse('checkout:payment-details'))
            submission = self.build_submission(
                bankcard=bankcard_form.bankcard)
            return self.submit(**submission)

        # Check bankcard form is valid
        if not bankcard_form.is_valid():
            ctx = self.get_context_data(**kwargs)
            ctx['bankcard_form'] = bankcard_form
            return self.render_to_response(ctx)

        # Render preview page (with bankcard details hidden)
        return self.render_preview(request, bankcard_form=bankcard_form)
示例#22
0
    def handle_payment_details_submission(self, request):
        # Validate the submitted forms
        bankcard_form = BankcardForm(request.POST)
        shipping_address = self.get_shipping_address(
            self.request.basket)
        address_form = BillingAddressForm(shipping_address, request.POST)

        if address_form.is_valid() and bankcard_form.is_valid():
            # If both forms are valid, we render the preview view with the
            # forms hidden within the page. This seems odd but means we don't
            # have to store sensitive details on the server.
            return self.render_preview(
                request, bankcard_form=bankcard_form,
                billing_address_form=address_form)

        # Forms are invalid - show them to the customer along with the
        # validation errors.
        return self.render_payment_details(
            request, bankcard_form=bankcard_form,
            billing_address_form=address_form)
示例#23
0
    def handle_payment_details_submission(self, request):
        # Validate the submitted forms
        post=request.POST
        paypal_form = PaymentForm(request.POST)
        bc_args = {
            'number': post['acct'],
            'expiry_month_0': post['expdate_0'],
            'expiry_month_1': post['expdate_1'],
            'ccv': post['cvv2']
        }
        print 'bc_args'
        print bc_args
        print 'post'
        print post
        #print bc_args
        #number=post['acct']
        #expiry_month_0 = post['expdate_0']
        #expiry_month_1 = post['expdate_1']
        #ccv = post['ccv2']
        bankcard_form = BankcardForm(bc_args)
        print 'valid bcform?'
        print bankcard_form.is_valid()
        #print bankcard_form.backard
        #shipping_address = self.get_shipping_address(
        #    self.request.basket)
        #address_form = BillingAddressForm(shipping_address, request.POST)
        #print address_form.is_valid()
        #print request.POST
        #print bankcard_form.is_valid()

        if paypal_form.is_valid() and bankcard_form.is_valid(): #address_form.is_valid() and bankcard_form.is_valid():
            # If both forms are valid, we render the preview view with the
            # forms hidden within the page. This seems odd but means we don't
            # have to store sensitive details on the server.
            return self.render_preview(request, paypal_form=paypal_form, bankcard_form=bankcard_form)#, billing_address_form=address_form)

        # Forms are invalid - show them to the customer along with the
        # validation errors.
        return self.render_payment_details(request, paypal_form=paypal_form, bankcard_form=bankcard_form)#,billing_address_form=address_form)
示例#24
0
    def handle_place_order_submission(self, request):
        bankcard_form = BankcardForm(request.POST)
        shipping_address = self.get_shipping_address(
            self.request.basket)
        address_form = BillingAddressForm(shipping_address, request.POST)
        if address_form.is_valid() and bankcard_form.is_valid():
            # Forms still valid, let's submit an order
            submission = self.build_submission(
                order_kwargs={
                    'billing_address': address_form.save(commit=False),
                },
                payment_kwargs={
                    'bankcard_form': bankcard_form,
                    'billing_address_form': address_form
                }
            )
            return self.submit(**submission)

        # Must be DOM tampering as these forms were valid and were rendered in
        # a hidden element.  Hence, we don't need to be that friendly with our
        # error message.
        messages.error(request, _("Invalid submission"))
        return http.HttpResponseRedirect(
            reverse('checkout:payment-details'))
示例#25
0
文件: views.py 项目: joseanpz/carrito
 def get_context_data(self, **kwargs):
     ctx = super(PaymentDetailsView, self).get_context_data(**kwargs)
     # Ensure newly instantiated instances of the bankcard and billing
     # address forms are passed to the template context (when they aren't
     # already specified).
     if 'bankcard_form' not in kwargs:
         ctx['bankcard_form'] = BankcardForm()
     if 'billing_address_form' not in kwargs:
         ctx['billing_address_form'] = self.get_billing_address_form(
             ctx['shipping_address'])
     elif kwargs['billing_address_form'].is_valid():
         # On the preview view, we extract the billing address into the
         # template context so we can show it to the customer.
         ctx['billing_address'] = kwargs['billing_address_form'].save(
             commit=False)
     return ctx
示例#26
0
 def get_context_data(self, **kwargs):
     # Add bankcard form to the template context
     ctx = super(PaymentDetailsView, self).get_context_data(**kwargs)
     ctx['bankcard_form'] = kwargs.get('bankcard_form', BankcardForm())
     return ctx
示例#27
0
 def get_context_data(self, **kwargs):
     # Add bankcard form to the template context
     if 'bankcard_form' not in kwargs:
         kwargs['bankcard_form'] = BankcardForm()
     ctx = super(PaymentDetailsView, self).get_context_data(**kwargs)
     return ctx