

def balance_remaining(request):
    'Allow the user to pay the remaining balance.'
    order = None
    orderid = request.session.get('orderID')
    if orderid:
        try:
            order = Order.objects.get(pk=orderid)
        except Order.DoesNotExist:
            pass
    if (not order):
        url = urlresolvers.reverse('satchmo_checkout-step1')
        return HttpResponseRedirect(url)
    if (request.method == 'POST'):
        new_data = request.POST.copy()
        form = PaymentMethodForm(data=new_data, order=order)
        if form.is_valid():
            data = form.cleaned_data
            modulename = data['paymentmethod']
            if (not modulename.startswith('PAYMENT_')):
                modulename = ('PAYMENT_' + modulename)
            paymentmodule = config_get_group(modulename)
            url = lookup_url(paymentmodule, 'satchmo_checkout-step2')
            return HttpResponseRedirect(url)
    else:
        form = PaymentMethodForm(order=order)
    ctx = RequestContext(request, {
        'form': form,
        'order': order,
        'paymentmethod_ct': len(active_gateways()),
    })
    return render_to_response('shop/checkout/balance_remaining.html', context_instance=ctx)

dataset/ETHPy150Open dokterbob/satchmo/satchmo/apps/payment/views/balance.py balance_remaining/original