Пример #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)
Пример #2
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)