Example #1
0
    def _cart_xml(self, order):
        template = get_template(self.settings["CART_XML_TEMPLATE"].value)

        shopping_url = lookup_url(self.settings, 'satchmo_checkout-success', True, self.settings.SSL.value)
        edit_url = lookup_url(self.settings, 'satchmo_cart', True, self.settings.SSL.value)
        ctx = Context({"order" : order,
                       "continue_shopping_url" : shopping_url,
                       "edit_cart_url" : edit_url,
                       "currency" : self.settings.CURRENCY_CODE.value,
                       })
        return template.render(ctx)
Example #2
0
def credit_pay_ship_info(request, payment_module):
    #First verify that the customer exists
    contact = Contact.from_request(request, create=False)
    if contact is None:
        url = lookup_url(payment_module, 'satchmo_checkout-step1')
        return http.HttpResponseRedirect(url)

    #Verify we still have items in the cart
    if request.session.get('cart', False):
        tempCart = Cart.objects.get(id=request.session['cart'])
        if tempCart.numItems == 0:
            template = lookup_template(payment_module, 'checkout/empty_cart.html')
            return render_to_response(template, RequestContext(request))
    else:
        return render_to_response('checkout/empty_cart.html', RequestContext(request))
    #Verify order info is here
    if request.POST:
        new_data = request.POST.copy()
        form = CreditPayShipForm(request, payment_module, new_data)
        if form.is_valid():
            data = form.cleaned_data

            # Create a new order
            newOrder = Order(contact=contact)
            pay_ship_save(newOrder, tempCart, contact,
                shipping=data['shipping'], discount=data['discount'])
            request.session['orderID'] = newOrder.id

            #TODO: allow partial-pay here, which will mean that not all payments are on new orders.
            orderpayment = OrderPayment(order=newOrder, amount=newOrder.balance,
                payment=unicode(payment_module.KEY.value))
            orderpayment.save()
            # Save the credit card information
            cc = CreditCardDetail(orderpayment=orderpayment, ccv=data['ccv'],
                expireMonth=data['month_expires'],
                expireYear=data['year_expires'],
                creditType=data['credit_type'])
            cc.storeCC(data['credit_number'])
            cc.save()

            url = lookup_url(payment_module, 'satchmo_checkout-step3')
            return http.HttpResponseRedirect(url)
    else:
        form = CreditPayShipForm(request, payment_module)

    template = lookup_template(payment_module, 'checkout/pay_ship.html')
    ctx = {
        'form' : form,
        'PAYMENT_LIVE' : payment_live(payment_module)
    }
    return render_to_response(template, ctx, RequestContext(request))
Example #3
0
    def _cart_xml(self, order):
        template = get_template(self.settings["CART_XML_TEMPLATE"].value)

        shopping_url = lookup_url(self.settings, 'satchmo_checkout-success',
                                  True, self.settings.SSL.value)
        edit_url = lookup_url(self.settings, 'satchmo_cart', True,
                              self.settings.SSL.value)
        ctx = Context({
            "order": order,
            "continue_shopping_url": shopping_url,
            "edit_cart_url": edit_url,
            "currency": self.settings.CURRENCY_CODE.value,
        })
        return template.render(ctx)
Example #4
0
def confirm_info(request):
    payment_module = config_get_group('PAYMENT_PAYPAL')

    if not request.session.get('orderID'):
        url = lookup_url(payment_module, 'satchmo_checkout-step1')
        return HttpResponseRedirect(url)

    if request.session.get('cart'):
        tempCart = Cart.objects.get(id=request.session['cart'])
        if tempCart.numItems == 0:
            template = lookup_template(payment_module, 'checkout/empty_cart.html')
            return render_to_response(template, RequestContext(request))
    else:
        template = lookup_template(payment_module, 'checkout/empty_cart.html')
        return render_to_response(template, RequestContext(request))

    order = Order.objects.get(id=request.session['orderID'])

    # Check if the order is still valid
    if not order.validate(request):
        context = RequestContext(request,
            {'message': _('Your order is no longer valid.')})
        return render_to_response('shop_404.html', context)

    template = lookup_template(payment_module, 'checkout/paypal/confirm.html')
    if payment_module.LIVE.value:
        log.debug("live order on %s", payment_module.KEY.value)
        url = payment_module.POST_URL.value
        account = payment_module.BUSINESS.value
    else:
        url = payment_module.POST_TEST_URL.value
        account = payment_module.BUSINESS_TEST.value
        
    try:
        address = lookup_url(payment_module, payment_module.RETURN_ADDRESS.value, include_server=True)
    except urlresolvers.NoReverseMatch:
        address = payment_module.RETURN_ADDRESS.value
        
    ctx = RequestContext(request, {'order': order,
     'post_url': url,
     'business': account,
     'currency_code': payment_module.CURRENCY_CODE.value,
     'return_address': address,
     'PAYMENT_LIVE' : payment_live(payment_module)
    })

    return render_to_response(template, ctx)
Example #5
0
def simple_pay_ship_info(request, payment_module, template):
    """A pay_ship view which doesn't require a credit card"""
    #First verify that the customer exists
    contact = Contact.from_request(request, create=False)
    if contact is None:
        url = lookup_url(payment_module, 'satchmo_checkout-step1')
        return http.HttpResponseRedirect(url)
    #Verify we still have items in the cart
    if request.session.get('cart', False):
        tempCart = Cart.objects.get(id=request.session['cart'])
        if tempCart.numItems == 0:
            template = lookup_template(payment_module, 'checkout/empty_cart.html')
            return render_to_response(template, RequestContext(request))
    else:
        template = lookup_template(payment_module, 'checkout/empty_cart.html')
        return render_to_response(template, RequestContext(request))

    #Verify order info is here
    if request.POST:
        new_data = request.POST.copy()
        form = SimplePayShipForm(request, payment_module, new_data)
        if form.is_valid():
            data = form.cleaned_data

            # Create a new order
            newOrder = Order(contact=contact)
            pay_ship_save(newOrder, tempCart, contact,
                shipping=data['shipping'], discount=data['discount'])
            request.session['orderID'] = newOrder.id

            #TODO: allow partial-pay here, which will mean that not all payments are on new orders.
            orderpayment = OrderPayment(order=newOrder, amount=newOrder.balance, payment=payment_module.KEY.value)
            orderpayment.save()

            url = lookup_url(payment_module, 'satchmo_checkout-step3')
            return http.HttpResponseRedirect(url)
    else:
        form = SimplePayShipForm(request, payment_module)

    template = lookup_template(payment_module, template)
    ctx = {
        'form' : form,
        'PAYMENT_LIVE' : payment_live(payment_module)
    }
    return render_to_response(template, ctx, RequestContext(request))
Example #6
0
def contact_info(request):
    """View which collects demographic information from customer."""

    #First verify that the cart exists and has items
    if request.session.get('cart'):
        tempCart = Cart.objects.get(id=request.session['cart'])
        if tempCart.numItems == 0:
            return render_to_response('checkout/empty_cart.html', RequestContext(request))
    else:
        return render_to_response('checkout/empty_cart.html', RequestContext(request))

    init_data = {}
    areas, countries, only_country = get_area_country_options(request)

    contact = Contact.from_request(request, create=False)

    if request.POST:
        new_data = request.POST.copy()
        if not tempCart.is_shippable:
            new_data['copy_address'] = True
        form = PaymentContactInfoForm(countries, areas, new_data,
            initial=init_data)

        if form.is_valid():
            if contact is None and request.user:
                contact = Contact(user=request.user)
            custID = form.save(contact=contact, update_newsletter=False)
            request.session['custID'] = custID
            #TODO - Create an order here and associate it with a session
            modulename = 'PAYMENT_' + new_data['paymentmethod']
            paymentmodule = config_get_group(modulename)
            url = lookup_url(paymentmodule, 'satchmo_checkout-step2')
            return http.HttpResponseRedirect(url)
    else:
        if contact:
            #If a person has their contact info, make sure we populate it in the form
            for item in contact.__dict__.keys():
                init_data[item] = getattr(contact,item)
            if contact.shipping_address:
                for item in contact.shipping_address.__dict__.keys():
                    init_data["ship_"+item] = getattr(contact.shipping_address,item)
            if contact.billing_address:
                for item in contact.billing_address.__dict__.keys():
                    init_data[item] = getattr(contact.billing_address,item)
            if contact.primary_phone:
                init_data['phone'] = contact.primary_phone.phone
        else:
            # Allow them to login from this page.
            request.session.set_test_cookie()
        form = PaymentContactInfoForm(countries, areas, initial=init_data)

    context = RequestContext(request, {
        'form': form,
        'country': only_country,
        'paymentmethod_ct': len(config_value('PAYMENT', 'MODULES'))
        })
    return render_to_response('checkout/form.html', context)
Example #7
0
def one_step(request):
    payment_module = config_get_group('PAYMENT_AUTOSUCCESS')

    #First verify that the customer exists
    contact = Contact.from_request(request, create=False)
    if contact is None:
        url = lookup_url(payment_module, 'satchmo_checkout-step1')
        return http.HttpResponseRedirect(url)
    #Verify we still have items in the cart
    if request.session.get('cart', False):
        tempCart = Cart.objects.get(id=request.session['cart'])
        if tempCart.numItems == 0:
            template = lookup_template(payment_module,
                                       'checkout/empty_cart.html')
            return render_to_response(template, RequestContext(request))
    else:
        template = lookup_template(payment_module, 'checkout/empty_cart.html')
        return render_to_response(template, RequestContext(request))

    # Create a new order
    newOrder = Order(contact=contact)
    pay_ship_save(newOrder, tempCart, contact, shipping="", discount="")

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

    newOrder.add_status(status='Pending', notes="Order successfully submitted")

    orderpayment = OrderPayment(order=newOrder,
                                amount=newOrder.balance,
                                payment=payment_module.KEY.value)
    orderpayment.save()

    #Now, send a confirmation email
    if payment_module['EMAIL'].value:
        shop_config = Config.get_shop_config()
        shop_email = shop_config.store_email
        shop_name = shop_config.store_name
        t = loader.get_template('email/order_complete.txt')
        c = Context({'order': newOrder, 'shop_name': shop_name})
        subject = "Thank you for your order from %s" % shop_name

        try:
            email = orderToProcess.contact.email
            body = t.render(c)
            send_mail(subject, body, shop_email, [email], fail_silently=False)
        except SocketError, e:
            if settings.DEBUG:
                log.error('Error sending mail: %s' % e)
                log.warn(
                    'Ignoring email error, since you are running in DEBUG mode.  Email was:\nTo:%s\nSubject: %s\n---\n%s',
                    email, subject, body)
            else:
                log.fatal('Error sending mail: %s' % e)
                raise IOError(
                    'Could not send email, please check to make sure your email settings are correct, and that you are not being blocked by your ISP.'
                )
Example #8
0
def contact_info(request):
    """View which collects demographic information from customer."""

    # First verify that the cart exists and has items
    if request.session.get("cart"):
        tempCart = Cart.objects.get(id=request.session["cart"])
        if tempCart.numItems == 0:
            return render_to_response("checkout/empty_cart.html", RequestContext(request))
    else:
        return render_to_response("checkout/empty_cart.html", RequestContext(request))

    init_data = {}
    areas, countries, only_country = get_area_country_options(request)

    contact = Contact.from_request(request, create=False)

    if request.POST:
        new_data = request.POST.copy()
        if not tempCart.is_shippable:
            new_data["copy_address"] = True
        form = PaymentContactInfoForm(countries, areas, new_data, initial=init_data)

        if form.is_valid():
            if contact is None and request.user:
                contact = Contact(user=request.user)
            custID = form.save(contact=contact, update_newsletter=False)
            request.session["custID"] = custID
            # TODO - Create an order here and associate it with a session
            modulename = "PAYMENT_" + new_data["paymentmethod"]
            paymentmodule = config_get_group(modulename)
            url = lookup_url(paymentmodule, "satchmo_checkout-step2")
            return http.HttpResponseRedirect(url)
    else:
        if contact:
            # If a person has their contact info, make sure we populate it in the form
            for item in contact.__dict__.keys():
                init_data[item] = getattr(contact, item)
            if contact.shipping_address:
                for item in contact.shipping_address.__dict__.keys():
                    init_data["ship_" + item] = getattr(contact.shipping_address, item)
            if contact.billing_address:
                for item in contact.billing_address.__dict__.keys():
                    init_data[item] = getattr(contact.billing_address, item)
            if contact.primary_phone:
                init_data["phone"] = contact.primary_phone.phone
        else:
            # Allow them to login from this page.
            request.session.set_test_cookie()
        form = PaymentContactInfoForm(countries, areas, initial=init_data)

    context = RequestContext(
        request, {"form": form, "country": only_country, "paymentmethod_ct": len(config_value("PAYMENT", "MODULES"))}
    )
    return render_to_response("checkout/form.html", context)
Example #9
0
def one_step(request):
    payment_module = config_get_group('PAYMENT_AUTOSUCCESS')

    #First verify that the customer exists
    contact = Contact.from_request(request, create=False)
    if contact is None:
        url = lookup_url(payment_module, 'satchmo_checkout-step1')
        return http.HttpResponseRedirect(url)
    #Verify we still have items in the cart
    if request.session.get('cart', False):
        tempCart = Cart.objects.get(id=request.session['cart'])
        if tempCart.numItems == 0:
            template = lookup_template(payment_module, 'checkout/empty_cart.html')
            return render_to_response(template, RequestContext(request))
    else:
        template = lookup_template(payment_module, 'checkout/empty_cart.html')
        return render_to_response(template, RequestContext(request))

    # Create a new order
    newOrder = Order(contact=contact)
    pay_ship_save(newOrder, tempCart, contact,
        shipping="", discount="")
        
    request.session['orderID'] = newOrder.id
        
    newOrder.add_status(status='Pending', notes = "Order successfully submitted")

    orderpayment = OrderPayment(order=newOrder, amount=newOrder.balance, payment=payment_module.KEY.value)
    orderpayment.save()

    #Now, send a confirmation email
    if payment_module['EMAIL'].value:
        shop_config = Config.get_shop_config()
        shop_email = shop_config.store_email
        shop_name = shop_config.store_name
        t = loader.get_template('email/order_complete.txt')
        c = Context({'order': newOrder,
                      'shop_name': shop_name})
        subject = "Thank you for your order from %s" % shop_name
             
        try:
            email = orderToProcess.contact.email
            body = t.render(c)
            send_mail(subject, body, shop_email,
                      [email], fail_silently=False)
        except SocketError, e:
            if settings.DEBUG:
                log.error('Error sending mail: %s' % e)
                log.warn('Ignoring email error, since you are running in DEBUG mode.  Email was:\nTo:%s\nSubject: %s\n---\n%s', email, subject, body)
            else:
                log.fatal('Error sending mail: %s' % e)
                raise IOError('Could not send email, please check to make sure your email settings are correct, and that you are not being blocked by your ISP.')    
Example #10
0
def confirm_info(request):
    payment_module = config_get_group('PAYMENT_GOOGLE')

    if not request.session.get('orderID'):
        url = lookup_url(payment_module, 'satchmo_checkout-step1')
        return http.HttpResponseRedirect(url)

    if request.session.get('cart'):
        tempCart = Cart.objects.get(id=request.session['cart'])
        if tempCart.numItems == 0:
            template = lookup_template(payment_module,
                                       'checkout/empty_cart.html')
            return render_to_response(template, RequestContext(request))
    else:
        template = lookup_template(payment_module, 'checkout/empty_cart.html')
        return render_to_response(template, RequestContext(request))

    order = Order.objects.get(id=request.session['orderID'])

    # Check if the order is still valid
    if not order.validate(request):
        context = RequestContext(
            request, {'message': _('Your order is no longer valid.')})
        return render_to_response('shop_404.html', context)

    live = payment_live(payment_module)
    gcart = GoogleCart(order, payment_module, live)
    log.debug("CART:\n%s", gcart.cart_xml)
    template = lookup_template(payment_module, 'checkout/google/confirm.html')

    if live:
        merchant_id = payment_module.MERCHANT_ID.value
        url_template = payment_module.POST_URL.value
    else:
        merchant_id = payment_module.MERCHANT_TEST_ID.value
        url_template = payment_module.POST_TEST_URL.value

    post_url = url_template % {'MERCHANT_ID': merchant_id}

    ctx = RequestContext(
        request, {
            'order': order,
            'post_url': post_url,
            'google_cart': gcart.encoded_cart(),
            'google_signature': gcart.encoded_signature(),
            'PAYMENT_LIVE': live
        })

    return render_to_response(template, ctx)
Example #11
0
def confirm_info(request):
    payment_module = config_get_group('PAYMENT_GOOGLE')

    if not request.session.get('orderID'):
        url = lookup_url(payment_module, 'satchmo_checkout-step1')
        return http.HttpResponseRedirect(url)

    if request.session.get('cart'):
        tempCart = Cart.objects.get(id=request.session['cart'])
        if tempCart.numItems == 0:
            template = lookup_template(payment_module, 'checkout/empty_cart.html')
            return render_to_response(template, RequestContext(request))
    else:
        template = lookup_template(payment_module, 'checkout/empty_cart.html')
        return render_to_response(template, RequestContext(request))

    order = Order.objects.get(id=request.session['orderID'])

    # Check if the order is still valid
    if not order.validate(request):
        context = RequestContext(request,
            {'message': _('Your order is no longer valid.')})
        return render_to_response('shop_404.html', context)

    live = payment_live(payment_module)
    gcart = GoogleCart(order, payment_module, live)
    log.debug("CART:\n%s", gcart.cart_xml)
    template = lookup_template(payment_module, 'checkout/google/confirm.html')

    if live:
        merchant_id = payment_module.MERCHANT_ID.value
        url_template = payment_module.POST_URL.value
    else:
        merchant_id = payment_module.MERCHANT_TEST_ID.value
        url_template = payment_module.POST_TEST_URL.value
        
    post_url =  url_template % {'MERCHANT_ID' : merchant_id}

    ctx = RequestContext(request, {
        'order': order,
        'post_url': post_url,
        'google_cart' : gcart.encoded_cart(),
        'google_signature' : gcart.encoded_signature(),
        'PAYMENT_LIVE' : live
    })

    return render_to_response(template, ctx)
Example #12
0
def credit_confirm_info(request, payment_module):
    """A view which shows and requires credit card selection"""
    if not request.session.get('orderID'):
        url = urlresolvers.reverse('satchmo_checkout-step1')
        return HttpResponseRedirect(url)

    if request.session.get('cart'):
        tempCart = Cart.objects.get(id=request.session['cart'])
        if tempCart.numItems == 0:
            template = lookup_template(payment_module, 'checkout/empty_cart.html')
            return render_to_response(template, RequestContext(request))
    else:
        template = lookup_template(payment_module, 'checkout/empty_cart.html')
        return render_to_response(template, RequestContext(request))

    orderToProcess = Order.objects.get(id=request.session['orderID'])

    # Check if the order is still valid
    if not orderToProcess.validate(request):
        context = RequestContext(request,
            {'message': _('Your order is no longer valid.')})
        return render_to_response('shop_404.html', context)

    if request.POST:
        #Do the credit card processing here & if successful, empty the cart and update the status
        credit_processor = payment_module.MODULE.load_module('processor')
        processor = credit_processor.PaymentProcessor(payment_module)
        processor.prepareData(orderToProcess)
        results, reason_code, msg = processor.process()
        
        log.info("""Processing credit card transaction with %s
Order #%i
Results=%s
Response=%s
Reason=%s""", payment_module.key, orderToProcess.id, results, reason_code, msg)

        if results:
            tempCart.empty()
            #Update status
            
            orderToProcess.add_status(status='Pending', notes = "Order successfully submitted")

            #Now, send a confirmation email
            shop_config = Config.get_shop_config()
            shop_email = shop_config.store_email
            shop_name = shop_config.store_name
            t = loader.get_template('email/order_complete.txt')
            c = Context({'order': orderToProcess,
                          'shop_name': shop_name})
            subject = "Thank you for your order from %s" % shop_name
                     
            try:
                email = orderToProcess.contact.email
                body = t.render(c)
                send_mail(subject, body, shop_email,
                          [email], fail_silently=False)
            except SocketError, e:
                if settings.DEBUG:
                    log.error('Error sending mail: %s' % e)
                    log.warn('Ignoring email error, since you are running in DEBUG mode.  Email was:\nTo:%s\nSubject: %s\n---\n%s', email, subject, body)
                else:
                    log.fatal('Error sending mail: %s' % e)
                    raise IOError('Could not send email, please check to make sure your email settings are correct, and that you are not being blocked by your ISP.')    
            
            #Redirect to the success page
            url = lookup_url(payment_module, 'satchmo_checkout-success')
            return HttpResponseRedirect(url)
        #Since we're not successful, let the user know via the confirmation page
        else:
            errors = msg
Example #13
0
    orderpayment.save()

    #Now, send a confirmation email
    if payment_module['EMAIL'].value:
        shop_config = Config.get_shop_config()
        shop_email = shop_config.store_email
        shop_name = shop_config.store_name
        t = loader.get_template('email/order_complete.txt')
        c = Context({'order': newOrder,
                      'shop_name': shop_name})
        subject = "Thank you for your order from %s" % shop_name
             
        try:
            email = orderToProcess.contact.email
            body = t.render(c)
            send_mail(subject, body, shop_email,
                      [email], fail_silently=False)
        except SocketError, e:
            if settings.DEBUG:
                log.error('Error sending mail: %s' % e)
                log.warn('Ignoring email error, since you are running in DEBUG mode.  Email was:\nTo:%s\nSubject: %s\n---\n%s', email, subject, body)
            else:
                log.fatal('Error sending mail: %s' % e)
                raise IOError('Could not send email, please check to make sure your email settings are correct, and that you are not being blocked by your ISP.')    
    
    
    tempCart.empty()
    success = lookup_url(payment_module, 'satchmo_checkout-success')
    return HttpResponseRedirect(success)

Example #14
0
def credit_confirm_info(request, payment_module):
    """A view which shows and requires credit card selection"""
    if not request.session.get('orderID'):
        url = urlresolvers.reverse('satchmo_checkout-step1')
        return HttpResponseRedirect(url)

    if request.session.get('cart'):
        tempCart = Cart.objects.get(id=request.session['cart'])
        if tempCart.numItems == 0:
            template = lookup_template(payment_module,
                                       'checkout/empty_cart.html')
            return render_to_response(template, RequestContext(request))
    else:
        template = lookup_template(payment_module, 'checkout/empty_cart.html')
        return render_to_response(template, RequestContext(request))

    orderToProcess = Order.objects.get(id=request.session['orderID'])

    # Check if the order is still valid
    if not orderToProcess.validate(request):
        context = RequestContext(
            request, {'message': _('Your order is no longer valid.')})
        return render_to_response('shop_404.html', context)

    if request.POST:
        #Do the credit card processing here & if successful, empty the cart and update the status
        credit_processor = payment_module.MODULE.load_module('processor')
        processor = credit_processor.PaymentProcessor(payment_module)
        processor.prepareData(orderToProcess)
        results, reason_code, msg = processor.process()

        log.info(
            """Processing credit card transaction with %s
Order #%i
Results=%s
Response=%s
Reason=%s""", payment_module.key, orderToProcess.id, results, reason_code, msg)

        if results:
            tempCart.empty()
            #Update status

            orderToProcess.add_status(status='Pending',
                                      notes="Order successfully submitted")

            #Now, send a confirmation email
            shop_config = Config.get_shop_config()
            shop_email = shop_config.store_email
            shop_name = shop_config.store_name
            t = loader.get_template('email/order_complete.txt')
            c = Context({'order': orderToProcess, 'shop_name': shop_name})
            subject = "Thank you for your order from %s" % shop_name

            try:
                email = orderToProcess.contact.email
                body = t.render(c)
                send_mail(subject,
                          body,
                          shop_email, [email],
                          fail_silently=False)
            except SocketError, e:
                if settings.DEBUG:
                    log.error('Error sending mail: %s' % e)
                    log.warn(
                        'Ignoring email error, since you are running in DEBUG mode.  Email was:\nTo:%s\nSubject: %s\n---\n%s',
                        email, subject, body)
                else:
                    log.fatal('Error sending mail: %s' % e)
                    raise IOError(
                        'Could not send email, please check to make sure your email settings are correct, and that you are not being blocked by your ISP.'
                    )

            #Redirect to the success page
            url = lookup_url(payment_module, 'satchmo_checkout-success')
            return HttpResponseRedirect(url)
        #Since we're not successful, let the user know via the confirmation page
        else:
            errors = msg
Example #15
0
            except SocketError, e:
                if settings.DEBUG:
                    log.error('Error sending mail: %s' % e)
                    log.warn(
                        'Ignoring email error, since you are running in DEBUG mode.  Email was:\nTo:%s\nSubject: %s\n---\n%s',
                        email, subject, body)
                else:
                    log.fatal('Error sending mail: %s' % e)
                    raise IOError(
                        'Could not send email, please check to make sure your email settings are correct, and that you are not being blocked by your ISP.'
                    )

            #Redirect to the success page
            url = lookup_url(payment_module, 'satchmo_checkout-success')
            return HttpResponseRedirect(url)
        #Since we're not successful, let the user know via the confirmation page
        else:
            errors = msg
    else:
        errors = ''

    template = lookup_template(payment_module, 'checkout/confirm.html')
    context = RequestContext(
        request, {
            'order': orderToProcess,
            'errors': errors,
            'checkout_step2': lookup_url(payment_module,
                                         'satchmo_checkout-step2')
        })
    return render_to_response(template, context)
Example #16
0
    orderpayment.save()

    #Now, send a confirmation email
    if payment_module['EMAIL'].value:
        shop_config = Config.get_shop_config()
        shop_email = shop_config.store_email
        shop_name = shop_config.store_name
        t = loader.get_template('email/order_complete.txt')
        c = Context({'order': newOrder, 'shop_name': shop_name})
        subject = "Thank you for your order from %s" % shop_name

        try:
            email = orderToProcess.contact.email
            body = t.render(c)
            send_mail(subject, body, shop_email, [email], fail_silently=False)
        except SocketError, e:
            if settings.DEBUG:
                log.error('Error sending mail: %s' % e)
                log.warn(
                    'Ignoring email error, since you are running in DEBUG mode.  Email was:\nTo:%s\nSubject: %s\n---\n%s',
                    email, subject, body)
            else:
                log.fatal('Error sending mail: %s' % e)
                raise IOError(
                    'Could not send email, please check to make sure your email settings are correct, and that you are not being blocked by your ISP.'
                )

    tempCart.empty()
    success = lookup_url(payment_module, 'satchmo_checkout-success')
    return HttpResponseRedirect(success)
Example #17
0
            try:
                email = orderToProcess.contact.email
                body = t.render(c)
                send_mail(subject, body, shop_email,
                          [email], fail_silently=False)
            except SocketError, e:
                if settings.DEBUG:
                    log.error('Error sending mail: %s' % e)
                    log.warn('Ignoring email error, since you are running in DEBUG mode.  Email was:\nTo:%s\nSubject: %s\n---\n%s', email, subject, body)
                else:
                    log.fatal('Error sending mail: %s' % e)
                    raise IOError('Could not send email, please check to make sure your email settings are correct, and that you are not being blocked by your ISP.')    
            
            #Redirect to the success page
            url = lookup_url(payment_module, 'satchmo_checkout-success')
            return HttpResponseRedirect(url)
        #Since we're not successful, let the user know via the confirmation page
        else:
            errors = msg
    else:
        errors = ''

    template = lookup_template(payment_module, 'checkout/confirm.html')
    context = RequestContext(request, {
        'order': orderToProcess,
        'errors': errors,
        'checkout_step2': lookup_url(payment_module, 'satchmo_checkout-step2')})
    return render_to_response(template, context)