def pay_notify(request): param=request.POST.dict() if ALIPAY.verify_notify(**param): out_trade_no=param['out_trade_no'] trade_no=param['trade_no'] total_fee=param['total_fee'] trade_status=param['trade_status'] order=Order.objects.get(out_trade_no=out_trade_no) if str(order.total_fee)==total_fee: if trade_status=='TRADE_FINISHED': print 'TRADE_FINISHED' if order.status!=1: order.status=1 order.trade_no=trade_no order.save() return HttpResponse('通知正常') elif trade_status=='TRADE_SUCCESS': print 'TRADE_SUCCESS' if order.status!=1: order.status=1 order.trade_no=trade_no order.save() return HttpResponse('通知正常') else: print 'ERR' return HttpResponse('通知不正确')
def to_pay(request,id): if not request.user.is_authenticated(): return redirect(reverse('user_login')) order=Order.objects.get(id=id) pay_url=ALIPAY.create_direct_pay_by_user_url(out_trade_no=order.out_trade_no, subject=order.subject, total_fee=str(order.total_fee), return_url=RETURN_URL, notify_url=NOTIFY_URL) return redirect(pay_url)