Example #1
0
def get_pay_url(data):  # name,total_price,payment
    name = data['name']
    total_price = data['price']
    payment = data['payment']
    out_order_id = data['out_order_id']
    name = name.replace('=', '_')  #防止k,v冲突
    if payment == '支付宝当面付':
        try:
            ali_order = AlipayF2F().create_order(name, out_order_id,
                                                 total_price)
        except Exception as e:
            print(e)
            return None
        if ali_order['code'] == '10000' and ali_order['msg'] == 'Success':
            return ali_order['qr_code']  #默认自带qrcode
        return None
        # return jsonify({'qr_code':'455555555454deffffffff'})
    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 pay_order.json()['url']
            return None
        except Exception as e:
            print(e)
            return None
        # 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:
            print(e)
            return None
        # 参数错误情况下,会失效
        if pay_order.json()['errmsg'] == 'success!':
            return pay_order.json()['url']
        return None
    elif payment in ['码支付微信', '码支付支付宝', '码支付QQ']:
        # 参数错误情况下,会失效
        try:
            qr_url = CodePay().create_order(payment, total_price, out_order_id)
            # print(qr_url)
        except Exception as e:
            print(e)
            return None
        return qr_url
    elif payment in ['PAYJS支付宝', 'PAYJS微信']:
        # 参数错误情况下,会失效
        try:
            r = Payjs().create_order(name, out_order_id, total_price)
        except Exception as e:
            print(e)
            return None
        if r and r.json()['return_msg'] == 'SUCCESS':
            return r.json()['code_url'], r.json()['payjs_order_id']
        return None
    elif payment in ['微信官方接口']:
        try:
            r = Wechat().create_order(name, out_order_id, total_price)
        except Exception as e:
            print(e)
            return None
        if r:
            return r
        return None
    elif payment in ['易支付']:
        try:
            r = Epay().create_order(name, out_order_id, total_price)
        except Exception as e:
            print(e)
            return None
        if r:
            return r
        return None
    elif payment in ['Mugglepay']:
        try:
            r = Mugglepay().create_order(name, out_order_id, total_price)
        except Exception as e:
            print(e)
            return None
        if r:
            return r
        return None
    else:
        return None
Example #2
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']:
        return '暂无该支付接口', 404
    if not all([name,out_order_id,total_price]):
        return '参数丢失', 404
    name = name.replace('=','_')  #防止k,v冲突        
    if payment == '支付宝当面付':
        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
        # return jsonify({'qr_code':'455555555454deffffffff'})
    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 ['微信官方接口']:
        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
Example #3
0
def get_pay_url():
    name = request.json.get('name', None).replace('=', '_')  #防止k,v冲突
    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微信'
    ]:
        return '暂无该支付接口', 404
    if not all([name, out_order_id, total_price]):
        return '参数丢失', 404
    if payment == '支付宝当面付':
        try:
            ali_order = alipay.api_alipay_trade_precreate(
                subject=name,
                out_trade_no=out_order_id,
                total_amount=total_price,
                notify_url=None)
        except Exception as e:
            log(e)
            return '支付宝处理失败', 504
        # print(ali_order)
        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)
        except Exception as e:
            log(e)
            return '数据库异常', 500
        # print(ali_order)
        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
    elif payment == '虎皮椒支付宝':
        obj = Hupi(payment='alipay')
        try:
            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 == '码支付微信' or '码支付支付宝' or '码支付QQ':
        # 参数错误情况下,会失效
        try:
            qr_url = codepay.create_order(payment, total_price, out_order_id)
        except Exception as e:
            log(e)
            return '数据库异常', 500
        return jsonify({'qr_code': qr_url})
    elif payment == 'PAYJS支付宝' or 'PAYJS微信':
        # 参数错误情况下,会失效
        try:
            r = payjs.create_order(name, out_order_id, total_price)
        except Exception as e:
            log(e)
            return '数据库异常', 500
        return jsonify({
            'qr_code': r.json()['code_url'],
            'payjs_order_id': r.json()['payjs_order_id']
        })
    else:
        return '开发中', 400