Ejemplo n.º 1
0
def booking_cancel(request, username, pk):
    if request.user.username != username and not request.user.has_perm("booking.change_booking"):
        raise PermissionDenied

    item = Booking.objects.get(id=pk)
    item.status = 3
    create_sms(item.booker, item, cancel=True)
    create_mail_book_cancel(item.booker, item)
    internal_book_cancel(item.booker, item)
    item.save()

    return HttpResponseRedirect(reverse("booking_history", args=[username]))
Ejemplo n.º 2
0
def handle_confirm(request):
    if request.method == "POST" and request.is_ajax():
        post_data = request.POST.copy()
        print post_data
        if request.session.get("pay_booking_id", False):
            item = Booking.objects.get(id=request.session["pay_booking_id"])
            item.status = 1
            item.pay_method = 1
            item.save()
            create_sms(item.booker, item)
            create_mail_book_confirm(item.booker, item)
            internal_book_confirm(item.booker, item)
            return HttpResponse("Y")
    raise PermissionDenied
Ejemplo n.º 3
0
def alipay_notify(request):
    """ Notify callback for alipay """
    alipay = Alipay(pid=settings.ALIPAY_PID, key=settings.ALIPAY_KEY, seller_email=settings.ALIPAY_SELLER_EMAIL)
    if alipay.verify_notify(**dict(request.POST.items())):
        if request.POST.get("trade_status") in ["WAIT_SELLER_SEND_GOODS", "TRADE_SUCCESS"]:
            order = Booking.objects.get(id=request.POST.get("out_trade_no"))
            order.status = 5
            order.pay_method = 2
            order.save()
            create_sms(order.booker, order)
            create_mail_book_confirm(order.booker, order)
            internal_book_confirm(order.booker, order)
            return HttpResponse("success")
        else:
            print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    return HttpResponse("failure")
Ejemplo n.º 4
0
def unipay_notify(request, id):
    """ Notify callback for unipay """
    order = get_object_or_404(Booking, id=id)
    if request.method == "POST":
        post_data = request.POST.copy()
        print post_data
        if post_data.get("payResult") == "1":
            order.status = 5
            order.pay_method = 3
            order.save()
            create_sms(order.booker, order)
            create_mail_book_confirm(order.booker, order)
            internal_book_confirm(order.booker, order)
            success_url = "/accounts/%s/edit/?orderNo=%s&orderAmount=%s&payResult=1&signMsg=%s" % (
                order.booker.username,
                post_data.get("orderNo"),
                post_data.get("orderAmount"),
                post_data.get("signMsg"),
            )
            return HttpResponseRedirect(success_url)
    return HttpResponse("failure")