Example #1
0
def one_step(request):
    # First verify that the customer exists
    try:
        contact = Contact.objects.from_request(request, create=False)
    except Contact.DoesNotExist:
        url = lookup_url(payment_config, "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(payment_config, "shop/checkout/empty_cart.html")
        return render_to_response(template, context_instance=RequestContext(request))

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

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

    processor = get_processor_by_key("PAYMENT_REWARD_POINTS")
    processor.prepare_data(newOrder)
    processor_result = processor.process(newOrder)

    if processor_result.success:
        tempCart.empty()
        return success(request)
    else:
        return failure(request)
Example #2
0
def one_step(request):
    payment_module = config_get_group('PAYMENT_AUTOSUCCESS')

    #First verify that the customer exists
    try:
        contact = Contact.objects.from_request(request, create=False)
    except Contact.DoesNotExist:
        url = lookup_url(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(payment_module, 'shop/checkout/empty_cart.html')
        return render_to_response(template,
                                  context_instance=RequestContext(request))

    # Create a new order
    newOrder = Order(contact=contact)
    pay_ship_save(newOrder, tempCart, contact,
        shipping="", discount="", notes="")
        
    request.session['orderID'] = newOrder.id
    
    processor = get_processor_by_key('PAYMENT_AUTOSUCCESS')
    processor.prepare_data(newOrder)
    payment = processor.process(newOrder)
        
    tempCart.empty()
    success = lookup_url(payment_module, 'satchmo_checkout-success')
    return HttpResponseRedirect(success)
Example #3
0
def one_step(request):
    payment_module = config_get_group('PAYMENT_AUTOSUCCESS')

    #First verify that the customer exists
    try:
        contact = Contact.objects.from_request(request, create=False)
    except Contact.DoesNotExist:
        url = lookup_url(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(payment_module,
                                   'shop/checkout/empty_cart.html')
        return render(request, template)

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

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

    processor = get_processor_by_key('PAYMENT_AUTOSUCCESS')
    processor.prepare_data(newOrder)
    payment = processor.process(newOrder)

    tempCart.empty()
    success = lookup_url(payment_module, 'satchmo_checkout-success')
    return HttpResponseRedirect(success)