Exemplo n.º 1
0
def giftcert_pay_ship_process_form(request, contact, working_cart, payment_module, allow_skip):
    if request.method == "POST":
        new_data = request.POST.copy()
        form = GiftCertPayShipForm(request, payment_module, new_data)
        if form.is_valid():
            data = form.cleaned_data

            # Create a new order.
            newOrder = get_or_create_order(request, working_cart, contact, data)            
            newOrder.add_variable(GIFTCODE_KEY, data['giftcode'])
            
            request.session['orderID'] = newOrder.id
            
            url = None
            gift_certificate = GiftCertificate.objects.get(code=data['giftcode'], valid=True, 
                    site=Site.objects.get_current())
            # Check to see if the giftcertificate is not enough
            # If it isn't, then process it and prompt for next payment method
            if gift_certificate.balance < newOrder.balance:
                controller = confirm.ConfirmController(request, gc)
                controller.confirm()
                url = reverse('satchmo_balance_remaining')
            else:
                url = lookup_url(payment_module, 'satchmo_checkout-step3')
            return (True, http.HttpResponseRedirect(url))
    else:
        form = GiftCertPayShipForm(request, payment_module)

    return (False, form)
Exemplo n.º 2
0
def giftcert_pay_ship_process_form(request, contact, working_cart, payment_module, allow_skip):
    if request.method == "POST":
        new_data = request.POST.copy()
        form = GiftCertPayShipForm(request, payment_module, new_data)
        if form.is_valid():
            data = form.cleaned_data

            # Create a new order.
            newOrder = get_or_create_order(request, working_cart, contact, data)            
            newOrder.add_variable(GIFTCODE_KEY, data['giftcode'])
            
            request.session['orderID'] = newOrder.id
            
            url = None
            gift_certificate = GiftCertificate.objects.get(code=data['giftcode'], valid=True, 
                    site=Site.objects.get_current())
            # Check to see if the giftcertificate is not enough
            # If it isn't, then process it and prompt for next payment method
            if gift_certificate.balance < newOrder.balance:
                controller = confirm.ConfirmController(request, gc)
                controller.confirm()
                url = reverse('satchmo_balance_remaining')
            else:
                url = lookup_url(payment_module, 'satchmo_checkout-step3')
            return (True, http.HttpResponseRedirect(url))
    else:
        form = GiftCertPayShipForm(request, payment_module)

    return (False, form)
Exemplo n.º 3
0
 def save(self, request, *args, **kwargs):
     contactid = super(PaymentContactInfoForm, self).save(*args, **kwargs)
     form_presave.send(PaymentContactInfoForm, form=self)
     contact = Contact.objects.get(pk=contactid)
     cart = kwargs.get('cart', None)
     if not cart:
         cart = Cart.objects.from_request(request)
     self.order = get_or_create_order(request, cart, contact, self.cleaned_data)
     form_postsave.send(PaymentContactInfoForm, form=self)
     return contactid
Exemplo n.º 4
0
 def save(self, request, *args, **kwargs):
     form_presave.send(PaymentContactInfoForm, form=self)
     contactid = super(PaymentContactInfoForm, self).save(*args, **kwargs)
     contact = Contact.objects.get(pk=contactid)
     cart = kwargs.get('cart', None)
     if not cart:
         cart = Cart.objects.from_request(request)
     self.order = get_or_create_order(request, cart, contact,
                                      self.cleaned_data)
     form_postsave.send(PaymentContactInfoForm, form=self)
     return contactid
Exemplo n.º 5
0
 def save(self, request, cart, contact, payment_module, data=None):
     form_presave.send(SimplePayShipForm, form=self)
     if data is None:
         data = self.cleaned_data
     self.order = get_or_create_order(request, cart, contact, data)
     if payment_module:
         processor_module = payment_module.MODULE.load_module('processor')
         processor = processor_module.PaymentProcessor(payment_module)
         self.orderpayment = processor.create_pending_payment(order=self.order)
     else:
         self.orderpayment = None
     form_postsave.send(SimplePayShipForm, form=self)
Exemplo n.º 6
0
 def save(self, request, cart, contact, payment_module, data=None):
     form_presave.send(SimplePayShipForm, form=self)
     if data is None:
         data = self.cleaned_data
     self.order = get_or_create_order(request, cart, contact, data)
     if payment_module:
         processor_module = payment_module.MODULE.load_module('processor')
         processor = processor_module.PaymentProcessor(payment_module)
         self.orderpayment = processor.create_pending_payment(order=self.order)
     else:
         self.orderpayment = None
     form_postsave.send(SimplePayShipForm, form=self)
    def __call__(self, request):
        #First verify that the customer exists
        try:
            contact = Contact.objects.from_request(request, create=False)
        except Contact.DoesNotExist:
            url = lookup_url(self.payment_module, 'satchmo_checkout-step1')
            return HttpResponseRedirect(url)
        #Verify we still have items in the cart
        tempCart = Cart.objects.from_request(request)
        if tempCart.numItems == 0:
            template = lookup_template(
                self.payment_module,
                'shop/checkout/empty_cart.html'
            )
            return render_to_response(
                template, context_instance=RequestContext(request)
            )
            
        data = {}
        if request.method == 'POST':
            data['discount'] = request.post.get('discount_code')
        
        
        success = lookup_url(
            self.payment_module,
            '%s_satchmo_checkout-success' % self.processor.key,
        )
        
        order = get_or_create_order(request, tempCart, contact, data)
        
        self.preprocess_order(order)
        
        # Add status
        order.add_status('New', _("Payment needs to be confirmed"))
        # Process payment
        self.processor.prepare_data(order)
        self.processor.process(order)
        tempCart.empty()

        self.postprocess_order(order)
        order.save()

        return HttpResponseRedirect(success)
    def __call__(self, request):
        #First verify that the customer exists
        try:
            contact = Contact.objects.from_request(request, create=False)
        except Contact.DoesNotExist:
            url = lookup_url(self.payment_module, 'satchmo_checkout-step1')
            return HttpResponseRedirect(url)
        #Verify we still have items in the cart
        tempCart = Cart.objects.from_request(request)
        if tempCart.numItems == 0:
            template = lookup_template(self.payment_module,
                                       'shop/checkout/empty_cart.html')
            return render_to_response(template,
                                      context_instance=RequestContext(request))

        data = {}
        if request.method == 'POST':
            data['discount'] = request.post.get('discount_code')

        success = lookup_url(
            self.payment_module,
            '%s_satchmo_checkout-success' % self.processor.key,
        )

        order = get_or_create_order(request, tempCart, contact, data)

        self.preprocess_order(order)

        # Add status
        order.add_status('New', _("Payment needs to be confirmed"))
        # Process payment
        self.processor.prepare_data(order)
        self.processor.process(order)
        tempCart.empty()

        self.postprocess_order(order)
        order.save()

        return HttpResponseRedirect(success)
Exemplo n.º 9
0
def giftcert_pay_ship_process_form(request, contact, working_cart, payment_module):
    if request.method == "POST":
        new_data = request.POST.copy()
        form = GiftCertPayShipForm(request, payment_module, new_data)
        if form.is_valid():
            data = form.cleaned_data

            # Create a new order.
            newOrder = get_or_create_order(request, working_cart, contact, data)            
            newOrder.add_variable(GIFTCODE_KEY, data['giftcode'])
            
            request.session['orderID'] = newOrder.id

            url = None
            if not url:
                url = lookup_url(payment_module, 'satchmo_checkout-step3')
                
            return (True, http.HttpResponseRedirect(url))
    else:
        form = GiftCertPayShipForm(request, payment_module)

    return (False, form)
Exemplo n.º 10
0
def simple_pay_ship_process_form(request, contact, working_cart, payment_module):
    if request.method == "POST":
        new_data = request.POST.copy()
        form = SimplePayShipForm(request, payment_module, new_data)
        if form.is_valid():
            form.save(request, working_cart, contact, payment_module)
    else:
        form = SimplePayShipForm(request, payment_module)
        if config_value('PAYMENT','USE_DISCOUNTS') or not form.shipping_hidden:
            return (False, form)
        else:
            # No discounts, no shipping choice = skip this step
            order = get_or_create_order(
                    request,
                    working_cart,
                    contact,
                    {'shipping': form.fields['shipping'].initial, 'discount': ''}
                    )
            processor_module = payment_module.MODULE.load_module('processor')
            processor = processor_module.PaymentProcessor(payment_module)
            orderpayment = processor.create_pending_payment(order=order)
    url = lookup_url(payment_module, 'satchmo_checkout-step3')
    return (True, http.HttpResponseRedirect(url))
Exemplo n.º 11
0
def giftcert_pay_ship_process_form(request, contact, working_cart,
                                   gateway_settings):
    if request.method == "POST":
        new_data = request.POST.copy()
        form = GiftCertPayShipForm(request, gateway_settings, new_data)
        if form.is_valid():
            data = form.cleaned_data

            # Create a new order.
            newOrder = get_or_create_order(request, working_cart, contact,
                                           data)
            newOrder.add_variable(GIFTCODE_KEY, data['giftcode'])

            request.session['orderID'] = newOrder.id

            url = None
            if not url:
                url = lookup_url(gateway_settings, 'satchmo_checkout-step3')

            return (True, http.HttpResponseRedirect(url))
    else:
        form = GiftCertPayShipForm(request, gateway_settings)

    return (False, form)
Exemplo n.º 12
0
 def save(self, request, cart, contact, payment_module):
     self.order = get_or_create_order(request, cart, contact, self.cleaned_data)
     processor_module = payment_module.MODULE.load_module('processor')
     processor = processor_module.PaymentProcessor(payment_module)
     self.orderpayment = processor.create_pending_payment(order=self.order)
     signals.form_save.send(SimplePayShipForm, form=self)