Ejemplo n.º 1
0
def defray_pay(request):
    """
    just tell the order-system that we have forked out enough money
    """
    try:
        if request.method == 'POST':
            user = request.user
            id = request.POST['id']
            o = order.objects.get(id=id)
            # TODO:FIXME: porting real defray interface

            if o is not None:
                try:
                    if appshop_generate(request, o) is True:
                        o.order_status = 1
                        o.save()
                        return render_to_response(
                            'success.html', {'url': 'cgi-bin/orders/review/'})
                except Exception, e:
                    o.order_status = 0xf
                    o.save()
                    return render_to_response(
                        'error.html', {
                            'msg': 'generate Failed(%s)' % e,
                            'url': 'cgi-bin/orders/review/'
                        })

            raise Exception('no such id %s' % id)
        else:
Ejemplo n.º 2
0
def paypal_execute(request):
    """
    Execute a Payment
    """
    try:
        payment_id = request.session.get('payment_id', default=None)
        payer_id = request.GET['PayerID']

        payment = paypalrestsdk.Payment.find(payment_id)
        payment_name = payment.transactions[0].item_list.items[0].name

        if payment.execute({"payer_id": payer_id}):
            # the payment has been accepted
            try:
                o = order.objects.get(order_payment_id=payment_id)
                o.order_payer_id = payer_id
                o.save()

                if appshop_generate(request, o) is True:
                    o.order_status = 1
                    o.save()
                    return render_to_response('success.html', {
                        'msg': 'pay success',
                        'url': 'cgi-bin/orders/review/'
                    })
            except Exception, e:
                o.order_status = 4
                o.save()
                return render_to_response(
                    'error.html', {
                        'msg': 'pay success but generate Failed(%s)' % e,
                        'url': 'cgi-bin/orders/review/'
                    })
        else:
Ejemplo n.º 3
0
def defray_pay(request):
    """
    just tell the order-system that we have forked out enough money
    """
    try:
        if request.method == "POST":
            user = request.user
            id = request.POST["id"]
            o = order.objects.get(id=id)
            # TODO:FIXME: porting real defray interface

            if o is not None:
                try:
                    if appshop_generate(request, o) is True:
                        o.order_status = 1
                        o.save()
                        return render_to_response("success.html", {"url": "cgi-bin/orders/review/"})
                except Exception, e:
                    o.order_status = 0xF
                    o.save()
                    return render_to_response(
                        "error.html", {"msg": "generate Failed(%s)" % e, "url": "cgi-bin/orders/review/"}
                    )

            raise Exception("no such id %s" % id)
        else:
Ejemplo n.º 4
0
def paypal_execute(request):
    """
    Execute a Payment
    """
    try:
        payment_id = request.session.get("payment_id", default=None)
        payer_id = request.GET["PayerID"]

        payment = paypalrestsdk.Payment.find(payment_id)
        payment_name = payment.transactions[0].item_list.items[0].name

        if payment.execute({"payer_id": payer_id}):
            # the payment has been accepted
            try:
                o = order.objects.get(order_payment_id=payment_id)
                o.order_payer_id = payer_id
                o.save()

                if appshop_generate(request, o) is True:
                    o.order_status = 1
                    o.save()
                    return render_to_response("success.html", {"msg": "pay success", "url": "cgi-bin/orders/review/"})
            except Exception, e:
                o.order_status = 4
                o.save()
                return render_to_response(
                    "error.html", {"msg": "pay success but generate Failed(%s)" % e, "url": "cgi-bin/orders/review/"}
                )
        else:
Ejemplo n.º 5
0
def orders_rebuild(request):
	try:
		if request.method == 'POST':
			old_id = request.POST['id']
			old_order = order.objects.get(id=old_id)
			if old_order is None:
				raise Exception('old order is not exist')
			else:
				if appshop_generate(request, old_order):
					if old_order.order_is_rebuild:
						old_order.order_status = 3
					else:
						old_order.order_status = 2

				return render_to_response('success.html', {'msg': 'rebuild OK', 'url': 'cgi-bin/orders/review/'})
		else:
			raise Exception('method is not post ')
	except Exception, e:
		return render_to_response('error.html', {'msg': '%s' % e, 'url': '/'})
Ejemplo n.º 6
0
def orders_rebuild(request):
    try:
        if request.method == "POST":
            old_id = request.POST["id"]
            old_order = order.objects.get(id=old_id)
            if old_order is None:
                raise Exception("old order is not exist")
            else:
                if appshop_generate(request, old_order):
                    if old_order.order_is_rebuild:
                        old_order.order_status = 3
                    else:
                        old_order.order_status = 2

                return render_to_response("success.html", {"msg": "rebuild OK", "url": "cgi-bin/orders/review/"})
        else:
            raise Exception("method is not post ")
    except Exception, e:
        return render_to_response("error.html", {"msg": "%s" % e, "url": "/"})