Esempio n. 1
0
    def testBalanceMethods(self):
        order = make_test_order(self.US, '', include_non_taxed=True)
        order.recalculate_total(save=False)
        price = order.total
        subtotal = order.sub_total

        self.assertEqual(subtotal, Decimal('105.00'))
        self.assertEqual(price, Decimal('115.00'))
        self.assertEqual(order.balance, price)

        paytype = active_gateways()[0][0].upper()

        pmt = OrderPayment(order=order,
                           payment=paytype,
                           amount=Decimal("5.00"))
        pmt.save()

        self.assertEqual(order.balance, Decimal("110.00"))
        self.assertEqual(order.balance_paid, Decimal("5.00"))

        self.assert_(order.is_partially_paid)

        pmt = OrderPayment(order=order,
                           payment=paytype,
                           amount=Decimal("110.00"))
        pmt.save()

        self.assertEqual(order.balance, Decimal("0.00"))
        self.assertEqual(order.is_partially_paid, False)
        self.assert_(order.paid_in_full)
Esempio n. 2
0
    def testBalanceMethods(self):
        order = make_test_order(self.US, '', include_non_taxed=True)
        order.recalculate_total(save=False)
        price = order.total
        subtotal = order.sub_total

        self.assertEqual(subtotal, Decimal('105.00'))
        self.assertEqual(price, Decimal('115.00'))
        self.assertEqual(order.balance, price)

        paytype = active_gateways()[0][0].upper()

        pmt = OrderPayment(order = order, payment=paytype, amount=Decimal("5.00"))
        pmt.save()

        self.assertEqual(order.balance, Decimal("110.00"))
        self.assertEqual(order.balance_paid, Decimal("5.00"))

        self.assert_(order.is_partially_paid)

        pmt = OrderPayment(order = order, payment=paytype, amount=Decimal("110.00"))
        pmt.save()

        self.assertEqual(order.balance, Decimal("0.00"))
        self.assertEqual(order.is_partially_paid, False)
        self.assert_(order.paid_in_full)
Esempio n. 3
0
File: config.py Progetto: 34/T
def labelled_gateway_choices():
    choices = []
    for module, group in active_gateways():
        defaultlabel = module.split('.')[-1]
        label = _(config_value(group, 'LABEL', default = defaultlabel))
        choices.append((group, label))

    signals.payment_choices.send(None, choices=choices)
    return choices
Esempio n. 4
0
    def make_order_payment(order, paytype=None, amount=None):
        if not paytype:
            paytype = active_gateways()[0][0]

        if not amount:
            amount = order.balance

        pmt = OrderPayment(order=order, payment=paytype.upper(), amount=amount)
        pmt.save()
        return pmt
Esempio n. 5
0
def make_order_payment(order, paytype=None, amount=None):
    if not paytype:
        paytype = active_gateways()[0][0]

    if not amount:
        amount = order.balance

    pmt = OrderPayment(order=order, payment=paytype.upper(), amount=amount)
    pmt.save()
    return pmt
Esempio n. 6
0
def labelled_gateway_choices():
    choices = []
    for module, group in active_gateways():
        defaultlabel = module.split('.')[-1]
        label = _(config_value(group, 'LABEL', default=defaultlabel))
        key = config_value(group, 'KEY')
        choices.append((key, label))

    signals.payment_choices.send(None, choices=choices)
    return choices
Esempio n. 7
0
    def testSmallPayment(self):
        order = make_test_order(self.US, '', include_non_taxed=True)
        order.recalculate_total(save=False)
        price = order.total
        subtotal = order.sub_total

        paytype = active_gateways()[0][0].upper()
        pmt = OrderPayment(order = order, payment=paytype, amount=Decimal("0.000001"))
        pmt.save()

        self.assert_(order.is_partially_paid)
Esempio n. 8
0
    def testSmallPayment(self):
        order = make_test_order(self.US, '', include_non_taxed=True)
        order.recalculate_total(save=False)
        price = order.total
        subtotal = order.sub_total

        paytype = active_gateways()[0][0].upper()
        pmt = OrderPayment(order = order, payment=paytype, amount=Decimal("0.000001"))
        pmt.save()

        self.assert_(order.is_partially_paid)
Esempio n. 9
0
def credit_choices(settings=None, include_module_if_no_choices=False):
    choices = []
    keys = []
    for module, group in active_gateways():
        vals = config_choice_values(group, 'CREDITCHOICES')
        for key, label in vals:
            if not key in keys:
                keys.append(key)
                pair = (key, ugettext(label))
                choices.append(pair)
        if include_module_if_no_choices and not vals:
            key = config_value(group, 'KEY')
            label = config_value(group, 'LABEL')
            pair = (key, ugettext(label))
            choices.append(pair)
    return choices
Esempio n. 10
0
def credit_choices(settings=None, include_module_if_no_choices=False):
    choices = []
    keys = []
    for module, group in active_gateways():
        vals = config_choice_values(group, 'CREDITCHOICES')
        for key, label in vals:
            if not key in keys:
                keys.append(key)
                pair = (key, ugettext(label))
                choices.append(pair)
        if include_module_if_no_choices and not vals:
            key = config_value(group, 'KEY')
            label = config_value(group, 'LABEL')
            pair = (key, ugettext(label))
            choices.append(pair)
    return choices
Esempio n. 11
0
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:
            # TODO: verify user against current user
            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)
Esempio n. 12
0
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:
            # TODO: verify user against current user
            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)
Esempio n. 13
0
 def get_context_data(self, **kwargs):
     context = super(BalanceRemainingView, self).get_context_data(**kwargs)
     context['paymentmethod_ct'] = len(active_gateways())
     return context