Exemplo n.º 1
0
def ship_order(request, pk):
    order = get_object_or_404(Order, pk=pk)
    if not order.shippable:
        return redirect("kishore_admin_dashboard")
    else:
        processor = utils.load_class(order.shipment_processor)()
        return processor.ship_order_view(request,order)
Exemplo n.º 2
0
 def get_player(self):
     if not self.remote_url:
         return DefaultPlayer(self)
     else:
         for backend in kishore_settings.KISHORE_AUDIO_BACKENDS:
             player = utils.load_class(backend)(self)
             if player.accepts_remote_url(self.remote_url):
                 return player
Exemplo n.º 3
0
    def _choices(self):
        choices = []
        for backend in kishore_settings.KISHORE_PAYMENT_BACKENDS:
            processor = utils.load_class(backend)(self.order)
            if processor.valid:
                choices.append([backend, processor.human_name, processor.priority])

        return [[x[0], x[1]] for x in sorted(choices, key=lambda y: y[2])]
Exemplo n.º 4
0
def process_payment(request):
    order = utils.get_or_create_order(request)

    if order.total == 0:
        return redirect("kishore_store")

    klass = utils.load_class(order.payment_processor)
    payment_processor = klass(order)
    valid = payment_processor.accept_payment(request)

    if valid:
        order.complete()
        utils.clear_session_vars(request)
        return render(request, "kishore/store/success.html",{'order':order})
    else:
        error = "We're sorry, there was a problem charging you, please try again."
        return render(request, "kishore/store/error.html",{'error':error})
Exemplo n.º 5
0
def payment(request):
    order = utils.get_or_create_order(request)

    if request.method == "POST":
        form = PaymentForm(request.POST, order=order)
        if form.is_valid():
            order.customer_name = form.cleaned_data['name']
            order.customer_email = form.cleaned_data['email']
            order.payment_processor = form.cleaned_data['processor']
            order.save()

            p = form.cleaned_data["processor"]
            klass = utils.load_class(p)
            processor = klass(order)
            return processor.get_response(request)
    else:
        cart = utils.get_or_create_cart(request)
        order.prepare_from_cart(cart)
        form = PaymentForm(order=order)

    return render(request, "kishore/store/payment.html",{'form':form,'order':order})
Exemplo n.º 6
0
    def prepare_from_cart(self, cart):
        # delete old order items
        self.orderitem_set.all().delete()

        subtotal = 0

        # create new ones
        for item in cart.cartitem_set.all():
            order_item = OrderItem.objects.create(
                order=self,
                product=item.product,
                quantity=item.quantity,
                unit_price=item.unit_price)
            subtotal += item.quantity * item.unit_price

        self.subtotal = subtotal

        # taxes
        klass = utils.load_class(kishore_settings.KISHORE_TAX_BACKEND)
        tax_processor = klass(self)
        self.tax = tax_processor.calculate_tax()

        self.save()
Exemplo n.º 7
0
def shipping_methods(request):
    backend = utils.load_class(kishore_settings.KISHORE_SHIPPING_BACKEND)()
    return backend.shipping_method_view(request)
Exemplo n.º 8
0
 def get_payment_processor(self):
     klass = utils.load_class(self.payment_processor)
     return klass(self)