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
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 payment == '支付宝当面付': if methord == 'check': 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 ['微信官方接口']: 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
def check_pay(data): # 查询接口 out_order_id = data['out_order_id'] payment = data['payment'] #其余订单信息 name = data['name'] contact = data['contact'] contact_txt = data['contact_txt'] total_price = data['price'] price = data['price'] num = 1 # 支付渠道校验 if payment == '支付宝当面付': try: res = AlipayF2F().check(out_order_id) except Exception as e: print(e) return None # res = True #临时测试 # print(result) if res: # 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=total_price, num=1, total_price=total_price) # print('提交结果1') # print(time()-start) return True return None elif payment in ['虎皮椒支付宝', '虎皮椒微信']: try: obj = Hupi() result = obj.Check(out_trade_order=out_order_id) except Exception as e: print(e) return None #失败订单 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) return True except: return None return None elif payment in ['码支付微信', '码支付支付宝', '码支付QQ']: 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) return True except: return None return None elif payment in ['PAYJS支付宝', 'PAYJS微信']: payjs_order_id = data['payjs_order_id'] 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) return True except: return None return None elif payment in ['微信官方接口']: try: r = Wechat().check(out_order_id) except Exception as e: print(e) return None if r: executor.submit(make_order, out_order_id, name, payment, contact, contact_txt, price, num, total_price) return True return None elif payment in ['易支付']: try: r = Epay().check(out_order_id) except Exception as e: print(e) return None if r: executor.submit(make_order, out_order_id, name, payment, contact, contact_txt, price, num, total_price) return True return None elif payment in ['Mugglepay']: try: r = Mugglepay().check(out_order_id) except Exception as e: print(e) return None if r: executor.submit(make_order, out_order_id, name, payment, contact, contact_txt, price, num, total_price) return True return None else: return None
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) # 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 payment == '支付宝当面付': if methord == 'check': try: result = alipay.api_alipay_trade_query( out_trade_no=out_order_id) except Exception as e: log(e) return '支付宝请求错误', 500 # print(result) if result.get("trade_status", "") == "TRADE_SUCCESS": 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) # print('提交结果1') # print(time()-start) return jsonify({'msg': 'success'}) return jsonify({'msg': 'not paid'}) #支付状态校验 else: #取消订单 alipay.api_alipay_trade_cancel(out_trade_no=out_order_id) return jsonify({'msg': '订单已取消'}) elif payment == '虎皮椒支付宝' or '虎皮椒微信': if methord == 'check': try: obj = Hupi() 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) return jsonify({'msg': 'success'}) except: return jsonify({'msg': '订单参数不正确'}) return jsonify({'msg': 'not paid'}) #支付状态校验 else: #取消订单 return jsonify({'msg': '订单已取消'}) elif payment == '码支付微信' or '码支付支付宝' or '码支付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) return jsonify({'msg': 'success'}) except: return jsonify({'msg': '订单参数不正确'}) return jsonify({'msg': 'not paid'}) #支付状态校验 else: #取消订单 return jsonify({'msg': '订单已取消'}) elif payment == 'PAYJS支付宝' or '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) return jsonify({'msg': 'success'}) except: return jsonify({'msg': '订单参数不正确'}) return jsonify({'msg': 'not paid'}) #支付状态校验 else: #取消订单 return jsonify({'msg': '订单已取消'}) else: return '开发中', 400