Esempio n. 1
0
def pay_url(payment, name, out_order_id, total_price):
    name = name.replace('=', '_')  #防止k,v冲突
    try:
        if payment == '支付宝当面付':
            # return jsonify({'qr_code':'455555555454deffffffff'})
            r = AlipayF2F().create_order(name, out_order_id, total_price)
        elif payment == '虎皮椒微信':
            r = Hupi().Pay(trade_order_id=out_order_id,
                           total_fee=total_price,
                           title=name)
        elif payment == '虎皮椒支付宝':
            r = Hupi(payment='alipay').Pay(trade_order_id=out_order_id,
                                           total_fee=total_price,
                                           title=name)
        elif payment in ['码支付微信', '码支付支付宝', '码支付QQ']:
            if payment == '码支付微信':
                payname = 'wechat'
            elif payment == '码支付支付宝':
                payname = 'alipay'
            else:
                payname = 'qqpay'
            r = CodePay(payment=payname).create_order(payment, out_order_id,
                                                      total_price)
        elif payment in ['PAYJS支付宝', 'PAYJS微信']:
            r = Payjs().create_order(name, out_order_id, total_price)
        elif payment in ['V免签支付宝', 'V免签微信']:
            # 参数错误情况下,会失效
            if payment == 'V免签微信':
                r = VMQ().create_order(name, out_order_id, total_price)
            else:
                r = VMQ(payment='alipay').create_order(name, out_order_id,
                                                       total_price)
        elif payment in ['微信官方接口']:
            r = Wechat().create_order(name, out_order_id, total_price)
        elif payment in ['QQ钱包']:
            r = QQpay().create_order(name, out_order_id, total_price)
        elif payment in ['易支付']:
            r = Epay().create_order(name, out_order_id, total_price)
        elif payment in ['Mugglepay']:
            r = Mugglepay().create_order(name, out_order_id, total_price)
        elif payment in ['YunGouOS']:  # 统一接口
            r = YunGou(payment='unity').create_order(name, out_order_id,
                                                     total_price)
        elif payment in ['YunGouOS_WXPAY']:  # 微信接口
            r = YunGou().create_order_wxpay(name, out_order_id, total_price)
        else:
            return None
        return r
    except Exception as e:
        log(e)
        return False
Esempio n. 2
0
def check_pay_status(payment, out_order_id, payjs_order_id):  # 加入时间戳
    try:
        if payment == '支付宝当面付':
            r = AlipayF2F().check(out_order_id)
        elif payment in ['虎皮椒支付宝', '虎皮椒微信']:
            if payment == '虎皮椒微信':
                obj = Hupi()
            else:
                obj = Hupi(payment='alipay')
            r = obj.Check(out_trade_order=out_order_id)
        elif payment in ['码支付微信', '码支付支付宝', '码支付QQ']:
            r = CodePay().check(out_order_id)
        elif payment in ['PAYJS支付宝', 'PAYJS微信']:
            if payjs_order_id:
                r = Payjs().check(payjs_order_id)
        elif payment in ['V免签支付宝', 'V免签微信']:
            orderId = payjs_order_id
            r = VMQ().check(orderId)
        elif payment in ['微信官方接口']:
            r = Wechat().check(out_order_id)
        elif payment in ['易支付']:
            r = Epay().check(out_order_id)
        elif payment in ['Mugglepay']:
            r = Mugglepay().check(out_order_id)
        elif payment in ['YunGouOS', 'YunGouOS_WXPAY']:
            if payment == 'YunGouOS_WXPAY':
                r = YunGou().check(out_order_id)
            else:
                r = YunGou(payment='unity').check(out_order_id)
        else:
            return None
    except Exception as e:
        log(e)
        return False
    if r:
        # 状态更新--订单创建
        executor.submit(success_card,
                        out_order_id)  #success_card(out_order_id)
        return True
    return False
Esempio n. 3
0
def pay_url(payment, name, out_order_id, total_price):
    name = name.replace('=', '_')  # 防止k,v冲突
    try:
        if payment == '支付宝当面付':
            # return jsonify({'qr_code':'455555555454deffffffff'})
            r = AlipayF2F().create_order(name, out_order_id, total_price)
        elif payment == '虎皮椒微信':
            r = Hupi().Pay(trade_order_id=out_order_id,
                           total_fee=total_price,
                           title=name)
        elif payment == '虎皮椒支付宝':
            r = Hupi(payment='alipay').Pay(trade_order_id=out_order_id,
                                           total_fee=total_price,
                                           title=name)
        elif payment == '迅虎微信':
            r = Xunhu(payment='wechat').Pay(trade_order_id=out_order_id,
                                            total_fee=total_price,
                                            title=name)
        elif payment in ['码支付微信', '码支付支付宝', '码支付QQ']:
            if payment == '码支付微信':
                payname = 'wechat'
            elif payment == '码支付支付宝':
                payname = 'alipay'
            else:
                payname = 'qqpay'
            r = CodePay(payment=payname).create_order(payment, out_order_id,
                                                      total_price)
        elif payment in ['PAYJS支付宝', 'PAYJS微信']:
            if payment == 'PAYJS支付':
                payname = 'alipay'
            else:
                payname = 'wechat'
            r = Payjs(payment=payname).create_order(name, out_order_id,
                                                    total_price)
        elif payment in ['V免签支付宝', 'V免签微信']:
            # 参数错误情况下,会失效
            if payment == 'V免签微信':
                r = VMQ().create_order(name, out_order_id, total_price)
            else:
                r = VMQ(payment='alipay').create_order(name, out_order_id,
                                                       total_price)
        elif payment in ['微信官方接口']:
            r = Wechat().create_order(name, out_order_id, total_price)
        elif payment in ['QQ钱包']:
            r = QQpay().create_order(name, out_order_id, total_price)
        elif payment in ['易支付支付宝', '易支付QQ', '易支付微信']:
            if payment == '易支付支付宝':
                payname = 'alipay'
            elif payment == '易支付微信':
                payname = 'wechat'
            else:
                payname = 'qqpay'
            r = Epay(payment=payname).create_order(name, out_order_id,
                                                   total_price)
        elif payment in ['Mugglepay']:
            r = Mugglepay().create_order(name, out_order_id, total_price)
        elif payment in ['YunGouOS']:  # 统一接口
            r = YunGou(payment='unity').create_order(name, out_order_id,
                                                     total_price)
        elif payment in ['YunGouOS_WXPAY']:  # 微信接口
            r = YunGou().create_order_wxpay(name, out_order_id, total_price)
        elif payment in ['Stripe支付宝', 'Stripe微信']:  # 微信接口
            if payment == 'Stripe微信':
                r = Stripe(payment='wechat').create_order(
                    name, out_order_id, total_price)
            else:
                r = Stripe(payment='alipay').create_order(
                    name, out_order_id,
                    total_price)  # 导入cource_id和clinent_key[]合并
            if r:
                with db.auto_commit_db():
                    TempOrder.query.filter_by(
                        out_order_id=out_order_id).update(
                            {'contact_txt': r['signs']})
                r.pop('signs')
        elif payment in ['云免签微信', '云免签支付宝']:
            if payment == '云免签微信':
                r = Ymq(payment='wechat').create_order(name, out_order_id,
                                                       total_price)
            else:
                r = Ymq(payment='alipay').create_order(name, out_order_id,
                                                       total_price)
        else:
            return None
        return r
    except Exception as e:
        log(e)
        return False
Esempio n. 4
0
def notify(name):
    # print('请求地址:'+ request.url)
    # print(request.form.to_dict()) #适用于post请求,但是回调时get请求
    # print(request.args)
    try:
        if name == 'alipay':
            trade_status = request.form.get('trade_status', None)
            if trade_status and trade_status == 'TRADE_SUCCESS':
                res = AlipayF2F().verify(request.form.to_dict())
                if res:
                    out_order_id = request.form.get('out_trade_no', None)
                    executor.submit(notify_success, out_order_id)
        elif name == 'wechat':
            try:
                xml = request.data
                array_data = {}
                root = ET.fromstring(xml)
                for child in root:
                    value = child.text
                    array_data[child.tag] = value
                return_code = array_data['return_code']
                if return_code == 'SUCCESS':
                    res = Wechat().verify(array_data)
                    if res:
                        out_order_id = array_data['out_trade_no']
                        executor.submit(notify_success, out_order_id)
            except:
                pass
        elif name == 'xunhupay':
            trade_status = request.form.get('status', None)
            if trade_status and trade_status == 'OD':
                plugins = request.form.get('plugins', None)
                if plugins and plugins.find('wechat') != -1:
                    res = Hupi(payment='wechat').verify(request.form.to_dict())
                else:
                    res = Hupi(payment='alipay').verify(request.form.to_dict())
                if res:
                    out_order_id = request.form.get('trade_order_id', None)
                    executor.submit(notify_success, out_order_id)
        elif name == 'payjs':
            trade_status = request.form.get('return_code', None)
            if trade_status and trade_status == '1':
                attach = request.form.get('attach', None)
                if attach and attach.find('wechat') != -1:
                    res = Payjs(payment='wechat').verify(
                        request.form.to_dict())
                else:
                    res = Payjs(payment='alipay').verify(
                        request.form.to_dict())
                if res:
                    out_order_id = request.form.get('out_trade_no', None)
                    executor.submit(notify_success, out_order_id)
        elif name == 'vmq':
            out_order_id = request.args.get('payId', None)
            if out_order_id and len(out_order_id) == 27:
                payUrl = request.args.get('payUrl', None)
                if payUrl and payUrl.find('alipay') != -1:  # find找不着是返回-1
                    res = VMQ(payment='alipay').verify(request.args.to_dict())
                else:
                    res = VMQ(payment='wechat').verify(request.args.to_dict())
                if res:
                    executor.submit(notify_success, out_order_id)
        elif name == 'epay':
            trade_status = request.form.get('trade_status', None)
            if trade_status and trade_status == 'TRADE_SUCCESS':
                pay_type = request.form.get('type', None)
                if pay_type and pay_type == 'alipay':
                    payment = 'alipay'
                elif name == 'wxpay':
                    payment = 'wechat'
                else:
                    payment = 'qqpay'
                res = Epay(payment).verify(request.form.to_dict())
                if res:
                    out_order_id = request.form.get('out_trade_no', None)
                    executor.submit(notify_success, out_order_id)
        elif name == 'yungou':
            code = request.form.get('code', None)
            if code == '1':
                res = YunGou().verify(request.form.to_dict())
                if res:
                    out_order_id = request.form.get('outTradeNo', None)
                    executor.submit(notify_success, out_order_id)
        elif name == 'yungouwx':
            code = request.form.get('code', None)
            if code == '1':
                res = YunGou(payment='wechat').verify(request.form.to_dict())
                if res:
                    out_order_id = request.form.get('outTradeNo', None)
                    executor.submit(notify_success, out_order_id)
        elif name == 'codepay':
            pay_type = request.form.get('type', None)
            if pay_type:
                if pay_type == '3':
                    payment = 'wechat'
                elif pay_type == '2':
                    payment = 'qqpay'
                elif pay_type == '1':
                    payment = 'alipay'
                res = CodePay(payment).verify(request.form.to_dict())
                if res:
                    out_order_id = request.form.get('pay_id', None)
                    executor.submit(notify_success, out_order_id)
        elif name == 'qqpay':
            try:
                xml = request.data
                array_data = {}
                root = ET.fromstring(xml)
                for child in root:
                    value = child.text
                    array_data[child.tag] = value
                # print(array_data)
                trade_state = array_data['trade_state']
                if trade_state == 'SUCCESS':
                    res = QQpay().verify(array_data)
                    if res:
                        out_order_id = array_data['out_trade_no']
                        executor.submit(notify_success, out_order_id)
            except:
                pass
        elif name == 'mugglepay':
            status = request.form.get('status', None)
            if status and status == 'PAID':
                res = Mugglepay().verify(request.form.to_dict())
                if res:
                    out_order_id = request.form.get('merchant_order_id')
                    executor.submit(notify_success, out_order_id)
        elif name == 'stripe':
            source = request.args.get('source', None)  #id
            livemode = request.args.get('livemode', None)  #id
            client_secret = request.args.get('client_secret', None)  #id
            if livemode == 'true' and client_secret and livemode and len(
                    client_secret) == 42 and len(source) == 28:
                # 开始查询
                executor.submit(stripe_check, source, client_secret)
        elif name == 'ymq':
            out_order_id = request.form.get('out_order_sn', None)
            if out_order_id and len(out_order_id) == 27:
                pay_way = request.form.get('pay_way', None)
                if pay_way and pay_way == 'wechat':
                    payment = 'wechat'
                elif pay_way == 'alipay':
                    payment = 'alipay'
                else:
                    pass
                res = Ymq(payment=payment).verify(request.form.to_dict())
                if res:
                    executor.submit(notify_success, out_order_id)
    except:
        pass
    return 'success'
Esempio n. 5
0
def notify(name):
    # print('请求地址:'+ request.url)
    # print(request.form.to_dict()) #适用于post请求,但是回调时get请求
    # print(request.args)
    if name == 'alipay':
        trade_status = request.form.get('trade_status', None)
        if trade_status == 'TRADE_SUCCESS':
            res = AlipayF2F().verify(request.form.to_dict())
            if res:
                out_order_id = request.form.get('out_trade_no', None)
                executor.submit(notify_success, out_order_id)
        return 'success'
    elif name == 'wechat':
        try:
            xml = request.data
            array_data = {}
            root = ET.fromstring(xml)
            for child in root:
                value = child.text
                array_data[child.tag] = value
            return_code = array_data['return_code']
            if return_code == 'SUCCESS':
                res = Wechat().verify(array_data)
                if res:
                    out_order_id = array_data['out_trade_no']
                    executor.submit(notify_success, out_order_id)
        except:
            pass
    elif name == 'xunhupay':
        trade_status = request.form.get('status', None)
        if trade_status == 'OD':
            res = Hupi(payment='wechat').verify(request.form.to_dict())
            if res:
                out_order_id = request.form.get('trade_order_id', None)
                executor.submit(notify_success, out_order_id)
    elif name == 'payjs':
        trade_status = request.form.get('return_code', None)
        if trade_status == '1':
            res = Payjs().verify(request.form.to_dict())
            if res:
                out_order_id = request.form.get('out_trade_no', None)
                executor.submit(notify_success, out_order_id)
    elif name == 'vmq':
        out_order_id = request.args.get('payId', None)
        if out_order_id and len(out_order_id) == 27:
            res = VMQ(payment='wechat').verify(request.args.to_dict())
            if res:
                executor.submit(notify_success, out_order_id)
    elif name == 'epay':
        trade_status = request.form.get('trade_status', None)
        if trade_status == 'TRADE_SUCCESS':
            res = Epay().verify(request.form.to_dict())
            if res:
                out_order_id = request.form.get('out_trade_no', None)
                executor.submit(notify_success, out_order_id)
    elif name == 'yungou':
        code = request.form.get('code', None)
        if code == '1':
            res = YunGou().verify(request.form.to_dict())
            if res:
                out_order_id = request.form.get('outTradeNo', None)
                executor.submit(notify_success, out_order_id)
    elif name == 'yungouwx':
        code = request.form.get('code', None)
        if code == '1':
            res = YunGou(payment='wechat').verify(request.form.to_dict())
            if res:
                out_order_id = request.form.get('outTradeNo', None)
                executor.submit(notify_success, out_order_id)
    elif name == 'codepay':
        pay_type = request.form.get('type', None)
        if pay_type:
            if pay_type == '3':
                payment = 'wechat'
            elif pay_type == '2':
                payment = 'qqpay'
            elif pay_type == '1':
                payment = 'alipay'
            res = CodePay(payment).verify(request.form.to_dict())
            if res:
                out_order_id = request.form.get('pay_id', None)
                executor.submit(notify_success, out_order_id)
    elif name == 'qqpay':
        try:
            xml = request.data
            array_data = {}
            root = ET.fromstring(xml)
            for child in root:
                value = child.text
                array_data[child.tag] = value
            # print(array_data)
            trade_state = array_data['trade_state']
            if trade_state == 'SUCCESS':
                res = QQpay().verify(array_data)
                if res:
                    out_order_id = array_data['out_trade_no']
                    executor.submit(notify_success, out_order_id)
        except:
            pass
    elif name == 'mugglepay':
        status = request.form.get('status', None)
        if status and status == 'PAID':
            res = Mugglepay().verify(request.form.to_dict())
            if res:
                out_order_id = request.form.get('merchant_order_id')
                executor.submit(notify_success, out_order_id)
    else:
        pass

    return 'success'
Esempio n. 6
0
def check_pay():
    # print(request.json)
    out_order_id = request.json.get('out_order_id', None)
    methord = request.json.get('methord', None)
    payment = request.json.get('payment', None)  #支付方式
    #其余订单信息
    name = request.json.get('name', None)  #
    contact = request.json.get('contact', None)  #
    contact_txt = request.json.get('contact_txt', None)  #备注
    price = request.json.get('price', None)  #
    num = request.json.get('num', None)  #
    total_price = request.json.get('total_price', None)  #
    auto = request.json.get('auto', None)  #
    if methord not in ['check', 'cancel']:
        return '请求方法不正确', 400
    if not out_order_id:
        return '参数丢失', 404
    if not all([name, contact, price, num, total_price]):
        return '参数丢失2', 400
    if int(num) > 0:
        # 支付渠道校验
        if payment == '支付宝当面付':
            if methord == 'check':
                # executor.submit(make_order,out_order_id,name,payment,contact,contact_txt,price,num,total_price,auto)
                # return jsonify({'msg':'success'})
                try:
                    r = AlipayF2F().check(out_order_id)
                except Exception as e:
                    log(e)
                    return '支付宝请求错误', 500
                # res = True  #临时测试
                # print(result)
                if r:
                    # start = time()
                    # print('支付成功1')  #默认1.38s后台执行时间;重复订单执行时间0.01秒;异步后,时间为0.001秒
                    # make_order(out_order_id,name,payment,contact,contact_txt,price,num,total_price)
                    executor.submit(make_order, out_order_id, name, payment,
                                    contact, contact_txt, price, num,
                                    total_price, auto)
                    # print('提交结果1')
                    # print(time()-start)
                    return jsonify({'msg': 'success'})
                return jsonify({'msg': 'not paid'})  #支付状态校验
            else:  #取消订单
                AlipayF2F().cancle(out_order_id)
                return jsonify({'msg': '订单已取消'})
        elif payment in ['虎皮椒支付宝', '虎皮椒微信']:
            if methord == 'check':
                try:
                    if payment == '虎皮椒微信':
                        obj = Hupi()
                    else:
                        obj = Hupi(payment='alipay')
                    result = obj.Check(out_trade_order=out_order_id)
                except Exception as e:
                    log(e)
                    return '虎皮椒请求错误', 502
                #失败订单
                try:
                    if result.json(
                    )['data']['status'] == "OD":  #OD(支付成功),WP(待支付),CD(已取消)
                        executor.submit(make_order, out_order_id, name,
                                        payment, contact, contact_txt, price,
                                        num, total_price, auto)
                        return jsonify({'msg': 'success'})
                except:
                    return jsonify({'msg': '订单参数不正确'})

                return jsonify({'msg': 'not paid'})  #支付状态校验
            else:  #取消订单
                return jsonify({'msg': '订单已取消'})
        elif payment in ['码支付微信', '码支付支付宝', '码支付QQ']:
            if methord == 'check':
                result = CodePay().check(out_order_id)
                #失败订单
                try:
                    if result['msg'] == "success":  #OD(支付成功),WP(待支付),CD(已取消)
                        executor.submit(make_order, out_order_id, name,
                                        payment, contact, contact_txt, price,
                                        num, total_price, auto)
                        return jsonify({'msg': 'success'})
                except:
                    return jsonify({'msg': '订单参数不正确'})

                return jsonify({'msg': 'not paid'})  #支付状态校验
            else:  #取消订单
                return jsonify({'msg': '订单已取消'})
        elif payment in ['PAYJS支付宝', 'PAYJS微信']:
            if methord == 'check':
                payjs_order_id = request.json.get('payjs_order_id', None)
                result = Payjs().check(payjs_order_id)
                #失败订单
                try:
                    if result:
                        executor.submit(make_order, out_order_id, name,
                                        payment, contact, contact_txt, price,
                                        num, total_price, auto)
                        return jsonify({'msg': 'success'})
                except:
                    return jsonify({'msg': '订单参数不正确'})

                return jsonify({'msg': 'not paid'})  #支付状态校验
            else:  #取消订单
                return jsonify({'msg': '订单已取消'})
        elif payment in ['V免签支付宝', 'V免签微信']:
            if methord == 'check':
                orderId = request.json.get('payjs_order_id', None)
                result = VMQ().check(orderId)
                #失败订单
                try:
                    if result:
                        executor.submit(make_order, out_order_id, name,
                                        payment, contact, contact_txt, price,
                                        num, total_price, auto)
                        return jsonify({'msg': 'success'})
                except:
                    return jsonify({'msg': '订单参数不正确'})

                return jsonify({'msg': 'not paid'})  #支付状态校验
            else:  #取消订单
                return jsonify({'msg': '订单已取消'})
        elif payment in ['微信官方接口']:
            try:
                r = Wechat().check(out_order_id)
            except Exception as e:
                log(e)
                return '数据库异常', 500
            if r:
                executor.submit(make_order, out_order_id, name, payment,
                                contact, contact_txt, price, num, total_price,
                                auto)
                return jsonify({'msg': 'success'})
            return jsonify({'msg': 'not paid'})
        elif payment in ['易支付']:
            try:
                r = Epay().check(out_order_id)
            except Exception as e:
                log(e)
                return '数据库异常', 500
            if r:
                executor.submit(make_order, out_order_id, name, payment,
                                contact, contact_txt, price, num, total_price,
                                auto)
                return jsonify({'msg': 'success'})
            return jsonify({'msg': 'not paid'})
        elif payment in ['Mugglepay']:
            try:
                r = Mugglepay().check(out_order_id)
            except Exception as e:
                log(e)
                return '数据库异常', 500
            if r:
                executor.submit(make_order, out_order_id, name, payment,
                                contact, contact_txt, price, num, total_price,
                                auto)
                return jsonify({'msg': 'success'})
            return jsonify({'msg': 'not paid'})
        elif payment in ['YunGouOS', 'YunGouOS_WXPAY']:
            try:
                if payment == 'YunGouOS_WXPAY':
                    r = YunGou().check(out_order_id)
                else:
                    r = YunGou(payment='unity').check(out_order_id)
            except Exception as e:
                log(e)
                return '数据库异常', 500
            if r:
                executor.submit(make_order, out_order_id, name, payment,
                                contact, contact_txt, price, num, total_price,
                                auto)
                return jsonify({'msg': 'success'})
            return jsonify({'msg': 'not paid'})
        else:
            return '开发中', 400
    return 'erro', 404
Esempio n. 7
0
def get_pay_url():
    name = request.json.get('name', None)
    out_order_id = request.json.get('out_order_id', None)
    total_price = request.json.get('total_price', None)
    payment = request.json.get('payment', None)
    if payment not in [
            '支付宝当面付', '虎皮椒微信', '虎皮椒支付宝', '码支付微信', '码支付支付宝', '码支付QQ',
            'PAYJS支付宝', 'PAYJS微信', '微信官方接口', '易支付', 'Mugglepay', 'YunGouOS',
            'YunGouOS_WXPAY', 'V免签微信', 'V免签支付宝'
    ]:
        return '暂无该支付接口', 404
    if not all([name, out_order_id, total_price]):
        return '参数丢失', 404
    name = name.replace('=', '_')  #防止k,v冲突
    if payment == '支付宝当面付':
        # return jsonify({'qr_code':'455555555454deffffffff'})
        try:
            ali_order = AlipayF2F().create_order(name, out_order_id,
                                                 total_price)
        except Exception as e:
            log(e)
            return '支付宝处理失败', 504
        if ali_order['code'] == '10000' and ali_order['msg'] == 'Success':
            return jsonify(ali_order)  #默认自带qrcode
        return '调用支付接口失败', 400

    elif payment == '虎皮椒微信':
        try:
            obj = Hupi()
            pay_order = obj.Pay(trade_order_id=out_order_id,
                                total_fee=total_price,
                                title=name)
            if pay_order.json()['errmsg'] == 'success!':
                """
                {'openid': 20205992711,
                'url_qrcode': 'https://api.xunhupay.com/payments/wechat/qrcode?id=20205992711&nonce_str=5073110106&time=1603170015&appid=201906121518&hash=2c079048857dde2da83c740d9dcf3ad0',
                'url': 'https://api.xunhupay.com/payments/wechat/index?id=20205992711&nonce_str=7001051163&time=1603170015&appid=201906121518&hash=9a0192253f1f502e0bff6da77540c4ee',
                'errcode': 0,
                'errmsg': 'success!',
                'hash': '2d63d86e7b405ab34ac28204ba77d6d6'}
                """
                return jsonify({'qr_code': pay_order.json()['url']})
            return '调用支付接口失败', 400
        except Exception as e:
            log(e)
            return '数据库异常', 500
        # print(ali_order)
    elif payment == '虎皮椒支付宝':

        try:
            obj = Hupi(payment='alipay')
            pay_order = obj.Pay(trade_order_id=out_order_id,
                                total_fee=total_price,
                                title=name)
        except Exception as e:
            log(e)
            return '数据库异常', 500
        # 参数错误情况下,会失效
        if pay_order.json()['errmsg'] == 'success!':
            return jsonify({'qr_code': pay_order.json()['url']})
        return '调用支付接口失败', 400
    elif payment in ['码支付微信', '码支付支付宝', '码支付QQ']:
        # 参数错误情况下,会失效
        try:
            qr_url = CodePay().create_order(payment, total_price, out_order_id)
            print(qr_url)
        except Exception as e:
            log(e)
            return '数据库异常', 500
        return jsonify({'qr_code': qr_url})
    elif payment in ['PAYJS支付宝', 'PAYJS微信']:
        # 参数错误情况下,会失效
        try:
            r = Payjs().create_order(name, out_order_id, total_price)
        except Exception as e:
            log(e)
            return '数据库异常', 500
        if r and r.json()['return_msg'] == 'SUCCESS':
            return jsonify({
                'qr_code': r.json()['code_url'],
                'payjs_order_id': r.json()['payjs_order_id']
            })
        return '调用支付接口失败', 400
    elif payment in ['V免签支付宝', 'V免签微信']:
        # 参数错误情况下,会失效
        try:
            if payment == 'V免签微信':
                r = VMQ().create_order(name, out_order_id, total_price)
            else:
                r = VMQ(payment='alipay').create_order(name, out_order_id,
                                                       total_price)
        except Exception as e:
            log(e)
            return '数据库异常', 500
        if r:
            return jsonify({
                'qr_code': r['payUrl'],
                'payjs_order_id': r['orderId'],
                'reallyPrice': r['reallyPrice']
            })
        return '调用支付失败,疑似安卓端掉线', 400
    elif payment in ['微信官方接口']:
        try:
            r = Wechat().create_order(name, out_order_id, total_price)
        except Exception as e:
            log(e)
            return '数据库异常', 500
        if r:
            return jsonify({'qr_code': r})
        return '调用支付接口失败', 400
    elif payment in ['易支付']:
        try:
            r = Epay().create_order(name, out_order_id, total_price)
        except Exception as e:
            log(e)
            return '数据库异常', 500
        if r:
            return jsonify({'qr_code': r})
        return '调用支付接口失败', 400
    elif payment in ['Mugglepay']:
        try:
            r = Mugglepay().create_order(name, out_order_id, total_price)
        except Exception as e:
            log(e)
            return '数据库异常', 500
        if r:
            return jsonify({'qr_code': r})
        return '调用支付接口失败', 400
    elif payment in ['YunGouOS']:  # 统一接口
        try:
            r = YunGou(payment='unity').create_order(name, out_order_id,
                                                     total_price)
        except Exception as e:
            log(e)
            return '数据库异常', 500
        if r:
            return jsonify({'qr_code': r})
        return '调用支付接口失败', 400
    elif payment in ['YunGouOS_WXPAY']:  # 微信接口
        try:
            r = YunGou().create_order_wxpay(name, out_order_id, total_price)
        except Exception as e:
            log(e)
            return '数据库异常', 500
        if r:
            return jsonify({'qr_code': r})
        return '调用支付接口失败', 400
    else:
        return '开发中', 400