def doAiGameCallback(self, rpath): serialno = TyContext.RunHttp.getRequestParam('serialno', '') resultcode = TyContext.RunHttp.getRequestParam('resultCode', '') resultmsg = TyContext.RunHttp.getRequestParam('resultMsg', '') gameUserId = TyContext.RunHttp.getRequestParam('gameUserId', '') # gameGold = TyContext.RunHttp.getRequestParam('gameGold', 0) order_paytype = TyContext.RunHttp.getRequestParam('payType', '') validatecode = TyContext.RunHttp.getRequestParam('validatecode', '') # requestTime = TyContext.RunHttp.getRequestParam('requestTime', '') # 限制ip请求 # clientIp = TyContext.RunHttp.get_client_ip() # TyContext.ftlog.info('TuYouPayAiGame.doAiGameCallback in clientIp=', clientIp) # iplist = clientIp.split('.') # if len(iplist) != 4 or iplist[0] != '202' or iplist[1] != '102' or iplist[2] != '39' : # return serialno if serialno == '' or resultcode == '' or resultmsg == '' or gameUserId == '' or order_paytype == '' or validatecode == '': return serialno tSign = serialno + gameUserId m = md5() m.update(tSign) vSign = m.hexdigest() if validatecode != vSign: TyContext.ftlog.info( 'TuYouPayAiGame.doAiGameCallback->ERROR, sign error !! sign=', validatecode, 'vSign=', vSign) return serialno # 解密得到原始游戏订单号 orderPlatformId = gameUserId TyContext.ftlog.info( 'TuYouPayAiGame.doAiGameCallback orderPlatformId=', orderPlatformId) if resultcode == '120': # if int(gameGold) == 0: # total_fee = -1 # else: # total_fee = int(gameGold) from tysdk.entity.pay.pay import TuyouPay TuyouPay.doBuyChargeCallback(orderPlatformId, -1, 'TRADE_FINISHED', TyContext.RunHttp.convertArgsToDict()) return serialno
def doAiGameMsgCallback(self, rpath): notifys = TyContext.RunHttp.convertArgsToDict() cpparam = notifys.get('cpparam', '') if not cpparam: appkeys = '62d55e5d5d47f5d0121d2049d6893bc1' return self._doAiGameMsgCallbackNew(appkeys, rpath) resultcode = notifys.get('resultCode', '') resultmsg = notifys.get('resultMsg', '') try: order_paytype = notifys['payType'] del notifys['payType'] notifys['sub_paytype'] = order_paytype except: order_paytype = '' validatecode = notifys.get('validatecode', '') # 限制ip请求 # clientIp = TyContext.RunHttp.get_client_ip() # TyContext.ftlog.info('TuYouPayAiGame.doAiGameMsgCallback in clientIp=', clientIp) # iplist = clientIp.split('.') # if len(iplist) != 4 or iplist[0] != '202' or iplist[1] != '102' or iplist[2] != '39' : # return cpparam if resultcode == '' or resultmsg == '' or cpparam == '' or order_paytype != 'isagSmsPay' or validatecode == '': return TuYouPayAiGame.XML_RET % ('1', cpparam) tSign = resultcode + cpparam m = md5() m.update(tSign) vSign = m.hexdigest() if validatecode != vSign: TyContext.ftlog.info( 'TuYouPayAiGame.__doAiGameMsgCallbackOld__->ERROR, sign error !! sign=', validatecode, 'vSign=', vSign) return TuYouPayAiGame.XML_RET % ('1', cpparam) # 解密得到原始游戏订单号 orderPlatformId = cpparam TyContext.ftlog.info( 'TuYouPayAiGame.__doAiGameMsgCallbackOld__ orderPlatformId=', orderPlatformId) if resultcode == '00': from tysdk.entity.pay.pay import TuyouPay TuyouPay.doBuyChargeCallback(orderPlatformId, -1, 'TRADE_FINISHED', notifys) return TuYouPayAiGame.XML_RET % ('0', cpparam)
def doWanDouJiaCallback(self, rpath): rparam = TyContext.RunHttp.convertArgsToDict() TyContext.ftlog.info('doWanDouJiaCallback->rparam=', rparam) transdata = rparam['content'] try: datas = json.loads(transdata) appId = datas['appKeyId'] except: TyContext.ftlog.exception() TyContext.ftlog.info( 'doWanDouJiaCallback->ERROR, sign error !! transdata=', transdata) return 'Fail' appKey = self.appkeys[str(appId)] sign = rparam['sign'] if self.verifySign(transdata, sign, appKey) != True: TyContext.ftlog.info( 'doWanDouJiaCallback->ERROR, sign error !! transdata=', transdata, 'sign=', sign) return 'Fail' orderPlatformId = datas['out_trade_no'] trade_status = 'TRADE_FINISHED' total_fee = int(float(datas['money'])) total_fee = total_fee / 100.0 from tysdk.entity.pay.pay import TuyouPay isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, total_fee, trade_status, rparam) if isOk: return 'Success' else: return 'Fail'
def do114Callback(cls, rpath): TyContext.ftlog.info('do114Callback start') rparam = TyContext.RunHttp.convertArgsToDict() try: orderPlatformId = rparam['cpOrderId'] appId = orderid.get_appid_frm_order_id(orderPlatformId) sign = rparam['signature'] except: TyContext.ftlog.info( 'do114Callback->ERROR, param error !! rparam=', rparam) return "failure" paykey_dict = TyContext.Configure.get_global_item_json( '114_paykeys', {}) appkey = str(paykey_dict[str(appId)]['appkey']) appsecret = str(paykey_dict[str(appId)]['appsecret']) # 签名校验 if not cls.__verify_sign(rparam, appkey, appsecret, sign): TyContext.ftlog.error( 'TuyouPay114.do114Callbacksign verify error !!') return "failure" from tysdk.entity.pay.pay import TuyouPay trade_status = 'TRADE_FINISHED' isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, -1, trade_status, rparam) if isOk: return "success" else: return "failure"
def doIDOCallback(cls, rpath): TyContext.ftlog.info('doIDOCallback start') rparam = TyContext.RunHttp.convertArgsToDict() try: orderidconfig = TyContext.Configure.get_global_item_json( 'IDO_orderid', {}) start = orderidconfig.get(str(rparam['price']), None)[0] end = orderidconfig.get(str(rparam['price']), None)[1] sortOrderPlatformId = rparam['order_code'][start:end] orderPlatformId = ShortOrderIdMap.get_long_order_id( sortOrderPlatformId) sign = rparam['sign'] except: TyContext.ftlog.error( 'doIDOCallback->ERROR, param error !! rparam=', rparam) return 'error' # 签名校验 if not cls.__verify_sign(rparam, sign): TyContext.ftlog.error( 'TuyouPayIDO.doIDOCallbacksign verify error !!') return 'error' from tysdk.entity.pay.pay import TuyouPay trade_status = 'TRADE_FINISHED' isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, -1, trade_status, rparam) if isOk: return 'successful' else: return 'error'
def doTianyiCallbackMsg(self, rpath): rparam = TyContext.RunHttp.convertArgsToDict() if not 'sig' in rparam: TyContext.ftlog.error('doTianyiCallbackMsg error, no sign !!!') return '{"resultCode":"1111","resultDesc":"参数错误"}' sign = rparam['sig'] del rparam['sig'] vSign = self.buildMySign(rparam) if sign != vSign: TyContext.ftlog.info( 'doTianyiCallbackMsg->ERROR, sign error !! sign=', sign, 'vSign=', vSign) return '{"resultCode":"2222","resultDesc":"sig不正确"}' # 原始游戏订单号 orderPlatformId = rparam['txId'] TyContext.ftlog.info( 'TuYouPayTianYi.doTianyiCallbackMsg orderPlatformId=', orderPlatformId) from tysdk.entity.pay.pay import TuyouPay if int(rparam['chargeResult']) == 0: trade_status = 'TRADE_FINISHED' total_fee = -1 isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, total_fee, trade_status, rparam) if isOk: return '{"resultCode":"0000","resultDesc":"通知成功"}' else: return '{"resultCode":"3333","resultDesc":"失败"}' pass
def doMo9payCallback(cls, rpath): rparam = TyContext.RunHttp.convertArgsToDict() TyContext.ftlog.info('TuyouPayMo9pay.doMo9payCallbackin rparam=', rparam) try: mo9appId = str(rparam['app_id']) orderPlatformId = rparam['invoice'] mo9config = TyContext.Configure.get_global_item_json( 'mo9_config', {}) config = mo9config.get(mo9appId, None) mo9paykey = str(config['paykey']) sign = rparam['sign'] except: TyContext.ftlog.info( 'doMo9payCallback->ERROR, param error !! rparam=', rparam) TyContext.ftlog.exception() return "error" # 签名校验 if not cls.__verify_sign(rparam, mo9paykey, sign): TyContext.ftlog.error( 'TuyouPayMo9pay.doMo9payCallback verify error !!') return "ILLEGAL SIGN" from tysdk.entity.pay.pay import TuyouPay trade_status = 'TRADE_FINISHED' isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, -1, trade_status, rparam) if isOk: return "OK" else: return "error"
def doDuoKuCallbackMsg(self, rpath): TyContext.ftlog.info('doDuoKuCallback start') rparam = TyContext.RunHttp.convertArgsToDict() try: orderPlatformId = rparam['cpdefinepart'] appId = orderid.get_appid_frm_order_id(orderPlatformId) sign = rparam['sign'] except: TyContext.ftlog.info( 'doDuoKuCallback->ERROR, param error !! rparam=', rparam) return "failure" paykey_dict = TyContext.Configure.get_global_item_json( 'duoku_paykeys', {}) paykey = str(paykey_dict[str(appId)]) # 签名校验 if not self.__verify_sign(rparam, paykey, sign): TyContext.ftlog.error( 'TuYouPayDuoKu.doDuoKuCallbacksign verify error !!') return "failure" from tysdk.entity.pay.pay import TuyouPay trade_status = 'TRADE_FINISHED' isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, -1, trade_status, rparam) if isOk: return "success" else: return "failure"
def doRdoCallback(cls, rpath): cb_rsp = {} rparam = TyContext.RunHttp.convertArgsToDict() try: orderNo = rparam['orderNo'] mcpid = rparam['mcpid'] feeCode = rparam['feeCode'] reqtime = rparam['reqtime'] sign = rparam['sign'] except: TyContext.ftlog.exception() TyContext.ftlog.info( 'doRdoCallback->ERROR, param error !! rparam=', rparam) return 'param error' orderPlatformId = orderNo[6:] # 签名校验 if not cls.__verify_sign(mcpid, feeCode, orderNo, reqtime, sign): TyContext.ftlog.error( 'TuyouPayRdo.doRdoCallback sign verify error !!') return 'sign error' trade_status = 'TRADE_FINISHED' total_fee = -1 from tysdk.entity.pay.pay import TuyouPay isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, total_fee, trade_status, rparam) if isOk: return 'prod delivery ok' else: return 'prod delivery failed'
def doDoumengCallback(cls, rpath): TyContext.ftlog.info('doDoumengCallback start') rparam = TyContext.RunHttp.convertArgsToDict() try: orderPlatformId = rparam['privstr'] appId = orderid.get_appid_frm_order_id(orderPlatformId) paykey_dict = TyContext.Configure.get_global_item_json( 'doumeng_paykeys', {}) paykey = str(paykey_dict[str(appId)]) sign = rparam['sign'] except: TyContext.ftlog.info( 'doDoumengCallback->ERROR, param error !! rparam=', rparam) return "fail" # 签名校验 if not cls.__verify_sign(rparam, paykey, sign): TyContext.ftlog.error( 'TuyouPayDoumeng.doDoumengCallback sign verify error !!') return "fail" from tysdk.entity.pay.pay import TuyouPay trade_status = 'TRADE_FINISHED' isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, -1, trade_status, rparam) if isOk: return "ok" else: return "fail"
def doHuaWeiCallback(self, rpath): rparam = TyContext.RunHttp.convertArgsToDict() TyContext.ftlog.info('doHuaWeiCallback->rparam=', rparam) try: orderPlatformId = rparam['requestId'] appId = TyContext.ServerControl.get_appid_frm_order_id(orderPlatformId) hwapps = TuyouPayHuaWei.HWAPPS[str(appId)] isOk = self.__check_ras_code__(hwapps, rparam, False) if isOk: total_fee = int(float(rparam['amount'])) try: # huawei sdk also use payType, which is tuyou's sub_paytype rparam['sub_paytype'] = rparam['payType'] del rparam['payType'] except: pass isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, total_fee, 'TRADE_FINISHED', rparam) if isOk: return '{"result":0}' else: return '{"result":3}' else: return '{"result":1}' except: TyContext.ftlog.exception() return '{"result":94}'
def doCardCallback(cls, rpath): iHmacStr = TyContext.RunHttp.getRequestParam('hmac', '') cHmacStr = cls.getCallBackHmacString() if iHmacStr != cHmacStr: TyContext.ftlog.error('TuYouPayYee.doCardCallback, hmac verification error') return 'error' rparam = TyContext.RunHttp.convertArgsToDict() mer_code = TyContext.RunHttp.getRequestParam('p1_MerId') if mer_code != TuYouPayYee.p1_MerId: TyContext.ftlog.error('TuYouPayYee.doCardCallback error, mer_code is not me !!!') return 'error' orderPlatformId = TyContext.RunHttp.getRequestParam('p2_Order') rparam['payType'] = 'yee.card' rparam['sub_paytype'] = TyContext.RunHttp.getRequestParam('p4_FrpId', 'na') from tysdk.entity.pay.pay import TuyouPay r1_Code = TyContext.RunHttp.getRequestParam('r1_Code') if r1_Code != '1': # 长连接通知,客户端支付失败 status = TyContext.RunHttp.getRequestParamInt('p8_cardStatus', 10000) TyContext.ftlog.error('TuYouPayYee.doCardCallback error, charge return error !!! status=', status) bank_pay_flag = u'支付失败,' + TuYouPayYee.code_map.get(status, 'status' + str(status)) TuyouPay.deliveryChargeError(orderPlatformId, rparam, bank_pay_flag, 1) return 'success' total_fee = int(float(TyContext.RunHttp.getRequestParam('p3_Amt'))) isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, total_fee, 'TRADE_FINISHED', rparam) if isOk: return 'success' else: return 'error'
def doYdMmCallbackMsg(self, rpath): rparam = TyContext.RunHttp.convertArgsToDict() orderPlatformId = TyContext.RunHttp.getRequestParam( 'platformOrderId', '') from tysdk.entity.pay.pay import TuyouPay result = TyContext.RunHttp.getRequestParam('result', '') if result != '1': # 长连接通知,客户端支付失败 TyContext.ftlog.error( 'doYdMmCallbackMsg return error: result(%d)' % result, 'is not 1 !!!') if orderPlatformId: TuyouPay.deliveryChargeError(orderPlatformId, rparam, u'支付失败', 1) return '{result:{success:1,orderPlatformId:"' + orderPlatformId + '"}}' trade_status = 'TRADE_FINISHED' total_fee = -1 isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, total_fee, trade_status, rparam) if isOk: return '{result:{success:1,orderPlatformId:"' + orderPlatformId + '"}}' else: return '{result:{success:0,orderPlatformId:"' + orderPlatformId + '"}}' pass
def doTencentCallback(self, rpath): rparam = TyContext.RunHttp.convertArgsToDict() TyContext.ftlog.info('doTencentCallback->rparam=', rparam) # XXX callback should include this parameter sig = rparam['sig'] if not self.verifySign(sig): TyContext.ftlog.info('doTencentCallback->ERROR, sig error !! sig=', sig) return '{"ret":0,"msg":"sig NOT OK"}' orderPlatformId = rparam['app_metadata'] # if datas['result'] != 0: # 长连接通知,客户端支付失败 # TyContext.ftlog.error('doTencentCallback error, charge return error !!!') # errorInfo = '腾讯-未知错误' # from tysdk.entity.pay.pay import TuyouPay # TuyouPay.deliveryChargeError(orderPlatformId, rparam, errorInfo, 1) # return 'ERROR' trade_status = 'TRADE_FINISHED' total_fee = float(rparam['amt']) total_fee = int(total_fee / 100) from tysdk.entity.pay.pay import TuyouPay isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, total_fee, trade_status, rparam) if isOk: return '{"ret":0,"msg":"OK"}' else: return '{"ret":0,"msg":"prod delivery NOT OK"}'
def __do_deliver__goods(cls, datas): if datas: if 'sign' in datas: del datas['sign'] result = datas.get('status', 0) orderPlatformId = datas.get('orderid', '') if orderPlatformId.find('-') > 0: orderPlatformId = orderPlatformId.split('-')[0] datas['third_orderid'] = datas['yborderid'] from tysdk.entity.pay.pay import TuyouPay if result != 1: # 长连接通知,客户端支付失败 TyContext.ftlog.error( 'doYdMmCallbackMsg error, charge return error !!!') TuyouPay.deliveryChargeError(orderPlatformId, datas, u'支付失败', 1) return '{"errorcode ":0, "status":0, "callback":1}' total_fee = int(float(datas.get('amount', -1))) if total_fee > 0: total_fee = total_fee / 100 isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, total_fee, 'TRADE_FINISHED', datas) if isOk: return '{"errorcode ":0, "status":1, "callback":1}' else: return '{"errorcode ":200000, "status":1, "callback":1}' else: return '{"errorcode ":200024, "callback":1}'
def doUuCunCallback(self, rpath): rparam = TyContext.RunHttp.convertArgsToDict() orderPlatformId = TyContext.RunHttp.getRequestParam( 'platformOrderId', '') result = TyContext.RunHttp.getRequestParam('result', '') sign = TyContext.RunHttp.getRequestParam('sign', '') # tSign = 'orderid='+orderPlatformId+'&result='+result+'&key='+TuYouPayLaoHu.sign_skey tSign = orderPlatformId + result + TuYouPayUuCun.sign_skey m = md5() m.update(tSign) vSign = m.hexdigest() if sign != vSign.upper(): TyContext.ftlog.info('doUuCunCallback->ERROR, sign error !! sign=', sign, 'vSign=', vSign) return '{result:{success:0,orderPlatformId:"' + orderPlatformId + '"}}' from tysdk.entity.pay.pay import TuyouPay if result != '1': # 长连接通知,客户端支付失败 TyContext.ftlog.error( 'doUuCunCallback error, charge return error !!!') TuyouPay.deliveryChargeError(orderPlatformId, rparam, u'支付失败', 1) return '{result:{success:1,orderPlatformId:"' + orderPlatformId + '"}}' trade_status = 'TRADE_FINISHED' total_fee = -1 isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, total_fee, trade_status, rparam) if isOk: return '{result:{success:1,orderPlatformId:"' + orderPlatformId + '"}}' else: return '{result:{success:0,orderPlatformId:"' + orderPlatformId + '"}}'
def doHuafubaoCallback(self, rpath): rparam = TyContext.RunHttp.convertArgsToDict() orderPlatformId = '' try: merId = rparam['merId'] goodsId = rparam['goodsId'] orderPlatformId = rparam['orderId'] merDate = rparam['merDate'] payDate = rparam['payDate'] amount = rparam['amount'] amtType = rparam['amtType'] bankType = rparam['bankType'] mobileId = rparam['mobileId'] transType = rparam['transType'] settleDate = rparam['settleDate'] merPriv = rparam['merPriv'] retCode = rparam['retCode'] version = rparam['version'] sign = rparam['sign'] except: TyContext.ftlog.exception() TyContext.ftlog.info( 'doHuafubaoCallback->ERROR, param error !! rparam=', rparam) retContent = merId + '|' + goodsId + '|' + orderPlatformId + '|' + merDate + '|' + '1111|fail|' + version ret_sign = rsaSign(retContent, 'huafubao') retContent = retContent + '|' + ret_sign retMsg = TuyouPayHuafubao.RET_MSG % (retContent) return retMsg # merId=9996&goodsId=100&orderId=133819&merDate=20090402&payDate=20090402&amount=1000&amtType=02&bankType=3&mobileId=13426399070&transType=0&settleDate=20090403&merPriv=&retCode=0000&version=3.0 baseString = 'merId=' + merId + '&goodsId=' + goodsId + '&orderId=' + orderPlatformId + '&merDate=' + merDate + '&payDate=' + payDate + '&amount=' + str( amount) + \ '&amtType=' + amtType + '&bankType=' + bankType + '&mobileId=' + mobileId + '&transType=' + transType + '&settleDate=' + settleDate + '&merPriv=' + merPriv + '&retCode=' + retCode + '&version=' + version # 签名校验 if rsaVerify(baseString, sign, 'huafubao') != True: TyContext.ftlog.info( 'doHuafubaoCallback->ERROR, sign error !! sign=', sign) retContent = merId + '|' + goodsId + '|' + orderPlatformId + '|' + merDate + '|' + '1111|fail|' + version ret_sign = rsaSign(retContent, 'huafubao') retContent = retContent + '|' + ret_sign retMsg = TuyouPayHuafubao.RET_MSG % (retContent) return retMsg from tysdk.entity.pay.pay import TuyouPay isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, -1, 'TRADE_FINISHED', rparam) if isOk: retContent = merId + '|' + goodsId + '|' + orderPlatformId + '|' + merDate + '|' + '0000|success|' + version else: retContent = merId + '|' + goodsId + '|' + orderPlatformId + '|' + merDate + '|' + '1111|fail|' + version ret_sign = rsaSign(retContent, 'huafubao') retContent = retContent + '|' + ret_sign retMsg = TuyouPayHuafubao.RET_MSG % (retContent) # ftlog.info('doHuafubaoCallback->retMsg, retMsg=', retMsg) return retMsg
def doYoukuCallback(cls, rpath): cb_rsp = {} rparam = TyContext.RunHttp.convertArgsToDict() try: orderPlatformId = rparam['apporderID'] appId = orderid.get_appid_frm_order_id(orderPlatformId) price = rparam['price'] uid = rparam['uid'] sign = rparam['sign'] except: TyContext.ftlog.exception() TyContext.ftlog.info( 'doYoukuCallback->ERROR, param error !! rparam=', rparam) cb_rsp['status'] = 'failed' cb_rsp['desc'] = '参数错误' return json.dumps(cb_rsp) paykey_dict = TyContext.Configure.get_global_item_json( 'youku_paykeys', {}) paykey = str(paykey_dict[str(appId)]) # 签名校验 if not cls.__verify_sign(rparam, paykey, sign): TyContext.ftlog.error( 'TuyouPayYouku.doYoukuCallback sign verify error !!') cb_rsp['status'] = 'failed' cb_rsp['desc'] = '签名验证失败' return json.dumps(cb_rsp) try: result = int(rparam['result']) success_amount = rparam['success_amount'] if result < 1 or result > 2: TyContext.ftlog.error('doYoukuCallback got failed result:', result) cb_rsp['status'] = 'failed' cb_rsp['desc'] = 'result(%d) is not 1 or 2' % result return json.dumps(cb_rsp) if result == 2: TyContext.ftlog.error( 'doYoukuCallback got partial success result:' 'success_amount is', success_amount) except: pass from tysdk.entity.pay.pay import TuyouPay trade_status = 'TRADE_FINISHED' isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, -1, trade_status, rparam) if isOk: cb_rsp['status'] = 'success' cb_rsp['desc'] = '发货成功' return json.dumps(cb_rsp) else: cb_rsp['status'] = 'failed' cb_rsp['desc'] = '发货失败' return json.dumps(cb_rsp)
def doLinkYunUnionCallback(self, rpath): rparam = TyContext.RunHttp.convertArgsToDict() orderPlatformId = '' try: mobileId = rparam['mobile'] serviceid = rparam['serviceid'] orderPlatformId = str(rparam['orderid'])[2:] msgcontent = rparam['msgcontent'] sign = rparam['sign'] except: TyContext.ftlog.exception() TyContext.ftlog.info( 'doLinkYunUnionCallback->ERROR, param error !! rparam=', rparam) return '0' # 效验sign tSign = str(mobileId) + '#' + str(serviceid) + '#' + str( msgcontent) + '#' + TuYouPayLinkYun.sign_skey m = md5() m.update(tSign) vSign = m.hexdigest() if sign != vSign: TyContext.ftlog.info( 'doLinkYunUnionCallback->ERROR, sign error !! sign=', sign, 'vSign=', vSign) return '0' if orderPlatformId == '': TyContext.ftlog.info( 'doLinkYunUnionCallback->ERROR, orderPlatformId error !! orderPlatformId=', orderPlatformId) return '0' orderPlatformId = ShortOrderIdMap.get_long_order_id(orderPlatformId) TyContext.RunMode.get_server_link(orderPlatformId) # 对凌云充值的订单,把手机号补充到订单信息里 self.__set_order_mobile__(orderPlatformId, mobileId) if msgcontent == '0:0': TuyouPay.doBuyChargeCallback(orderPlatformId, -1, 'TRADE_FINISHED', rparam) return '0'
def doXinYinHeCallback(self, rpath): rparam = TyContext.RunHttp.convertArgsToDict() TyContext.ftlog.info('doXinYinHeCallback->rparam=', rparam) orderPlatformId = '' try: result = rparam['result'] payMoney = rparam['payMoney'] orderPlatformId = rparam['orderno'] merId = rparam['merId'] verifyType = rparam['verifyType'] # sign = rparam['sign'] except: TyContext.ftlog.exception() TyContext.ftlog.info( 'doXinYinHeCallback->ERROR, param error !! rparam=', rparam) return 'fail' # 效验sign ''' tSign = str(result)+str(payMoney)+str(orderPlatformId)+str(merId)+str(verifyType) m = md5() m.update(tSign) vSign = m.hexdigest() if sign != vSign : TyContext.ftlog.info('doXinYinHeCallback->ERROR, sign error !! sign=', sign, 'vSign=', vSign) return 'fail' ''' if orderPlatformId == '': TyContext.ftlog.info( 'doXinYinHeCallback->ERROR, orderPlatformId error !! orderPlatformId=', orderPlatformId) return 'fail' TyContext.RunMode.get_server_link(orderPlatformId) if int(result) == 1 or int(result) == 2: trade_status = 'TRADE_FINISHED' # total_fee = int(float(payMoney) / 100) from tysdk.entity.pay.pay import TuyouPay TuyouPay.doBuyChargeCallback(orderPlatformId, -1, trade_status, rparam) return 'success'
def do360Callback(self, rpath): # args= {'mer_trade_code': ['3ed16f18-aae9-45f9-ae58-2df2a4034fe3'], 'input_cha': ['UTF-8' # ], 'bank_pay_flag': ['failed:81007:\xe6\x97\xa0\xe6\x95\x88\xe7\x9a\x84\xe5\x8d\xa1\xe5\x8f\xb7\xe5\xaf\x86\xe7\xa0\x81'], 'mer_code': [ # '3337100050'], 'gateway_trade_code': ['1AA0000A94CA82013041912123982027'], 'rec_amount': ['10'], 'inner_trade_code': ['08301204191212398 # 20'], 'sign': ['4c2ea11a263c9ec2ef9f545b85ec4186'], 'sign_type': ['MD5'], 'product_name': ['360Coin']} # {'bank_trade_code': ['GWR13041912144816935'], 'input_cha': ['UTF-8'], 'sign_type': # ['MD5'], 'bank_pay_flag': ['success'], 'mer_code': ['3337100050'], 'rec_amount': ['10'], 'bank_code': ['DX_CARD'], 'inner_trade_code': [' # 0830130419121425414'], 'product_name': ['360Coin'], 'pay_amount': ['20'], 'mer_trade_code': ['3ed16f18-aae9-48f9-ae58-2df2a4034fe3'], 'si # gn': ['19b64607388cfe14eee99073ed9d6b44'], 'gateway_trade_code': ['1AA0000FE33C52013041912142541410']} orderPlatformId = TyContext.RunHttp.getRequestParam('mer_trade_code') rparam = TyContext.RunHttp.convertArgsToDict() if not 'sign' in rparam: TyContext.ftlog.error('do360Callback error, no sign !!!') return 'error' sign = rparam['sign'] del rparam['sign'] vSign = self.buildMySign(rparam) if sign != vSign: TyContext.ftlog.error('do360Callback error, sign error !!!') return 'error' rparam['sign'] = sign mer_code = TyContext.RunHttp.getRequestParam('mer_code') if mer_code != TuYouPay360.merchant_code: TyContext.ftlog.error('do360Callback error, mer_code is not me !!!') return 'error' from tysdk.entity.pay.pay import TuyouPay bank_pay_flag = TyContext.RunHttp.getRequestParam('bank_pay_flag') if bank_pay_flag != 'success': # 长连接通知,客户端支付失败 TyContext.ftlog.error('do360Callback error, charge return error !!!') bank_pay_flag = bank_pay_flag.decode('utf-8') TuyouPay.deliveryChargeError(orderPlatformId, rparam, bank_pay_flag, 1) return 'success' trade_status = 'TRADE_FINISHED' total_fee = TyContext.RunHttp.getRequestParam('pay_amount') if total_fee == None: total_fee = TyContext.RunHttp.getRequestParam('rec_amount') # if TuYouPay360.DEBUG360 : # total_fee = float(total_fee) # if total_fee == 0.01 : # total_fee = 10 isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, total_fee, trade_status, rparam) if isOk: return 'success' else: return 'error'
def doMsgDxCallback(self, rpath): MchNo = TyContext.RunHttp.getRequestParam('MchNo', '') Phone = TyContext.RunHttp.getRequestParam('Phone', '') Fee = TyContext.RunHttp.getRequestParam('Fee', '') OrderId = TyContext.RunHttp.getRequestParam('OrderId', '') MobileType = TyContext.RunHttp.getRequestParam('MobileType', '') Sign = TyContext.RunHttp.getRequestParam('Sign', '') if MchNo == '' or Phone == '' or Fee == '' or OrderId == '' or Sign == '': return '401~参数错误~' eft_skey = '' try: eft_appid = OrderId[0:2] eft_skey = TuYouPayMsgDx.appkeys.get(eft_appid) except: TyContext.ftlog.exception() tSign = MchNo + Phone + Fee + OrderId + eft_skey m = md5() m.update(tSign) vSign = m.hexdigest() if Sign != vSign: TyContext.ftlog.info('doMsgDxCallback->ERROR, sign error !! sign=', Sign, 'vSign=', vSign, 'eft_skey=', eft_skey) return '555~数字签名错误~' # 解密得到原始游戏订单号 orderPlatformId = '' try: orderPlatformId = OrderId[2:] Fee = int(Fee) except: TyContext.ftlog.exception() TyContext.ftlog.info('TuYouPayMsgDx.doMsgDxCallback orderPlatformId=', orderPlatformId) notifys = { 'MchNo': MchNo, 'vouchMobile': Phone, 'OrderId': OrderId, 'third_orderid': MchNo } if MobileType == 'LT': notifys['payType'] = 'EFTChinaUnion.msg' elif MobileType == 'DX': notifys['payType'] = 'EFTChinaTelecom.msg' from tysdk.entity.pay.pay import TuyouPay from tysdk.entity.paythird.helper import PayHelper PayHelper.set_order_mobile(orderPlatformId, Phone, 'v2') isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, Fee, 'TRADE_FINISHED', notifys) if isOk: return '000~成功~' else: return '111~失败~'
def doLinkYunUnionCallback(self, rpath): rparam = TyContext.RunHttp.convertArgsToDict() orderPlatformId = '' try: mobileId = rparam['mobile'] serviceid = rparam['serviceid'] orderPlatformId = str(rparam['orderid'])[2:] msgcontent = rparam['msgcontent'] sign = rparam['sign'] except: TyContext.ftlog.exception() TyContext.ftlog.info( 'doLinkYunUnionCallback->ERROR, param error !! rparam=', rparam) return '0' # 效验sign tSign = str(mobileId) + '#' + str(serviceid) + '#' + str( msgcontent) + '#' + TuYouPayLinkYunApp.sign_skey m = md5() m.update(tSign) vSign = m.hexdigest() if sign != vSign: TyContext.ftlog.info( 'doLinkYunUnionCallback->ERROR, sign error !! sign=', sign, 'vSign=', vSign) return '0' if orderPlatformId == '': TyContext.ftlog.info( 'doLinkYunUnionCallback->ERROR, orderPlatformId error !! orderPlatformId=', orderPlatformId) return '0' if msgcontent == '0:0': from tysdk.entity.pay.pay import TuyouPay trade_status = 'TRADE_FINISHED' TuyouPay.doBuyChargeCallback(orderPlatformId, -1, trade_status, rparam) return '0' pass
def doZhuoWangCallback(self, rpath): xmldata = TyContext.RunHttp.get_body_content() xmldata = xmldata.replace('encoding="gbk"', 'encoding="utf-8"') xmldata = unicode(xmldata, encoding='gbk').encode('utf-8') TyContext.ftlog.info('zhuowangMdo encode->xmldata=', xmldata) transactionId = '' try: xmlroot = ElementTree.fromstring(xmldata) checkCode = xmlroot.find('checkCode').text transactionId = xmlroot.find('transactionId').text serviceId = xmlroot.find('serviceId').text spId = xmlroot.find('spId').text serviceType = xmlroot.find('serviceType').text feeType = xmlroot.find('feeType').text # 获取orderPlatformId orderPlatformId = '' parmMap = xmlroot.getiterator("paramMap")[0] for x in parmMap: k, v = x.getchildren() if k.text == 'command': orderPlatformId = v.text orderPlatformId = orderPlatformId.split(',')[-1] orderPlatformId = ShortOrderIdMap.get_long_order_id( orderPlatformId) except: TyContext.ftlog.exception() TyContext.ftlog.info( 'doZhuoWangCallback->ERROR, param error !! xmldata=', xmldata) return TuYouPayZhuoWang.XML_RET % (transactionId, '0') if len(orderPlatformId) != 14: TyContext.ftlog.info( 'doZhuoWangCallback->ERROR, orderPlatformId error !!', 'orderPlatformId=', orderPlatformId) return TuYouPayZhuoWang.XML_RET % (transactionId, '0') TyContext.RunMode.get_server_link(orderPlatformId) if str(checkCode) == '000': from tysdk.entity.pay.pay import TuyouPay trade_status = 'TRADE_FINISHED' notifys = {'xml': xmldata} isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, -1, trade_status, notifys) if isOk: ret_msg = TuYouPayZhuoWang.XML_RET % (transactionId, '1') else: ret_msg = TuYouPayZhuoWang.XML_RET % (transactionId, '0') ret_msg = unicode(ret_msg, encoding='utf-8').encode('gbk') return ret_msg pass
def doLinkYunLtsdkCallback(self, rpath): clientIp = TyContext.RunHttp.get_client_ip() TyContext.ftlog.info('doLinkYunLtsdkCallback in clientIp=', clientIp) ''' if not clientIp in ('219.238.157.144','125.39.218.102'): return '1' ''' rparam = TyContext.RunHttp.convertArgsToDict() orderPlatformId = '' try: mobileId = rparam['mobile'] transactionId = rparam['transactionId'] orderPlatformId = rparam['outTradeNo'] status = rparam['status'] except: TyContext.ftlog.exception() TyContext.ftlog.info( 'doLinkYunLtsdkCallback->ERROR, param error !! rparam=', rparam) return '1' if orderPlatformId == '': TyContext.ftlog.info( 'doLinkYunLtsdkCallback->ERROR, orderPlatformId error !! orderPlatformId=', orderPlatformId) return '1' orderPlatformId = ShortOrderIdMap.get_long_order_id(orderPlatformId) TyContext.RunMode.get_server_link(orderPlatformId) # 对凌云充值的订单,把手机号补充到订单信息里 self.__set_order_mobile__(orderPlatformId, mobileId) if int(status) == 4: TuyouPay.doBuyChargeCallback(orderPlatformId, -1, 'TRADE_FINISHED', rparam) return '0'
def doLinkYunCallback(self, rpath): rparam = TyContext.RunHttp.convertArgsToDict() orderPlatformId = '' try: orderId = rparam['orderId'] mobileId = rparam['mobileId'] # productCode = rparam['productCode'] price = rparam['price'] goodsInf = rparam['goodsInf'] orderPlatformId = str(goodsInf)[2:] sign = rparam['sign'] except: TyContext.ftlog.info( 'doLinkYunCallback->ERROR, param error !! rparam=', rparam) return '1||param error' # 效验sign tSign = str(orderId) + str(mobileId) + str(price) + str( goodsInf) + TuYouPayLinkYun.sign_skey m = md5() m.update(tSign) vSign = m.hexdigest() if sign != vSign: TyContext.ftlog.info( 'doLinkYunCallback->ERROR, sign error !! sign=', sign, 'vSign=', vSign) return '1||sign error' if orderPlatformId == '': TyContext.ftlog.info( 'doLinkYunCallback->ERROR, orderPlatformId error !! orderPlatformId=', orderPlatformId, 'goodsInf=', goodsInf) return '1||orderPlatformId error' orderPlatformId = ShortOrderIdMap.get_long_order_id(orderPlatformId) TyContext.RunMode.get_server_link(orderPlatformId) # 对凌云充值的订单,把手机号补充到订单信息里 self.__set_order_mobile__(orderPlatformId, mobileId) rparam['third_orderid'] = orderId total_fee = int(float(price) / 100) isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, total_fee, 'TRADE_FINISHED', rparam) if isOk: return '0||' else: return '1||charge fail'
def doCaiFuTongNotify(self, rpath): rparam = TyContext.RunHttp.convertArgsToDict() signQuery = rparam['sign'] del rparam['sign'] sk = rparam.keys() sk.sort() queryStr = "" for k in sk: queryStr = queryStr + str(k) + '=' + str(rparam[k]) + '&' signData = queryStr + 'key=' + TuyouPayTuyou.cft_key m = hashlib.md5() m.update(signData) sign = m.hexdigest().upper() if signQuery.upper() != sign: TyContext.ftlog.info( 'TuYouPayTuyou.doCaiFuTongNotify->ERROR, sign error !! signQuery=', signQuery, 'sign=', sign) return 'error' orderPlatformId = rparam['sp_billno'] from tysdk.entity.pay.pay import TuyouPay if rparam['pay_result'] != '0': # 长连接通知,客户端支付失败 TyContext.ftlog.error( 'TuYouPayTuyou.doCaiFuTongNotify error, charge return error !!!' ) errorInfo = '' if 'pay_info' in rparam: errorInfo = rparam['pay_info'] errorInfo = errorInfo.decode('utf-8') else: errorInfo = '财付通-未知错误' TuyouPay.deliveryChargeError(orderPlatformId, rparam, errorInfo, 1) return 'success' trade_status = 'TRADE_FINISHED' total_fee = int(float(rparam['total_fee'])) total_fee = int(total_fee / 100) isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, total_fee, trade_status, rparam) if isOk: return 'success' else: return 'error'
def doLinkYunCallback(self, rpath): rparam = TyContext.RunHttp.convertArgsToDict() orderPlatformId = '' try: orderId = rparam['orderId'] mobileId = rparam['mobileId'] # productCode = rparam['productCode'] price = rparam['price'] goodsInf = rparam['goodsInf'] orderPlatformId = str(goodsInf)[2:] sign = rparam['sign'] except: TyContext.ftlog.exception() TyContext.ftlog.info( 'doLinkYunCallback->ERROR, param error !! rparam=', rparam) return 'N' # 效验sign tSign = str(orderId) + str(mobileId) + str(price) + str( goodsInf) + TuYouPayLinkYunApp.sign_skey m = md5() m.update(tSign) vSign = m.hexdigest() if sign != vSign: TyContext.ftlog.info( 'doLinkYunCallback->ERROR, sign error !! sign=', sign, 'vSign=', vSign) return '1||sign error' if orderPlatformId == '': TyContext.ftlog.info( 'doLinkYunCallback->ERROR, orderPlatformId error !! orderPlatformId=', orderPlatformId, 'goodsInf=', goodsInf) return '1||orderPlatformId error' from tysdk.entity.pay.pay import TuyouPay trade_status = 'TRADE_FINISHED' total_fee = int(float(price) / 100) isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, total_fee, trade_status, rparam) if isOk: return '0||' else: return '1||charge fail' pass
def doLenovoCallback(self, rpath): rparam = TyContext.RunHttp.convertArgsToDict() TyContext.ftlog.info('doLenovoCallback->rparam=', rparam) transdata = rparam['transdata'] try: datas = json.loads(transdata) appId = datas['appid'] except: TyContext.ftlog.exception() TyContext.ftlog.info( 'doLenovoCallback->ERROR, sign error !! transdata=', transdata) return 'ERROR' appKey = self.appkeys[appId] sign = rparam['sign'] if self.verifySign(transdata, sign, appKey) != True: TyContext.ftlog.info( 'doLenovoCallback->ERROR, sign error !! transdata=', transdata, 'sign=', sign) return 'ERROR' orderPlatformId = datas['exorderno'] from tysdk.entity.pay.pay import TuyouPay if datas['result'] != 0: # 长连接通知,客户端支付失败 TyContext.ftlog.error( 'doLenovoCallback error, charge return error !!!') errorInfo = '联想-未知错误' TuyouPay.deliveryChargeError(orderPlatformId, rparam, errorInfo, 1) return 'ERROR' trade_status = 'TRADE_FINISHED' total_fee = float(datas['money']) total_fee = int(total_fee / 100) isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, total_fee, trade_status, rparam) if isOk: return 'SUCCESS' else: return 'ERROR'
def doJingDongCallback(self, rpath): appId = 0 jsondata = None try: jsondata = TyContext.RunHttp.getRequestParam('data') jsondata = base64.decodestring(jsondata) TyContext.ftlog.info('doJingDongCallback->jsondata=', jsondata) jsondata = json.loads(jsondata) appId = int(jsondata['gameId']) except: TyContext.ftlog.exception() TyContext.ftlog.info( 'doWanDouJiaCallback->ERROR, param error !! jsondata=', jsondata) return '{"retCode": "103","retMessage": "param error","data": ""}' rparam = TyContext.RunHttp.convertArgsToDict() if not 'sign' in rparam: TyContext.ftlog.error('doWanDouJiaCallback error, no sign !!!') return 'error' sign = rparam['sign'] del rparam['sign'] vSign = self.buildMySign(rparam, appId) if sign != vSign: TyContext.ftlog.info( 'doJingDongCallback->ERROR, sign error !! sign=', sign, 'vSign=', vSign) return '{"retCode": "105","retMessage": "sign error","data": ""}' orderPlatformId = jsondata['orderId'] trade_status = 'TRADE_FINISHED' total_fee = int(float(jsondata['chargeMoney'])) from tysdk.entity.pay.pay import TuyouPay isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, total_fee, trade_status, rparam) if isOk: # base64.b64encode('{"orderStatus": "0"}') == eyJvcmRlclN0YXR1cyI6ICIwIn0= return '{"retCode": "100","retMessage": "success","data": "eyJvcmRlclN0YXR1cyI6ICIwIn0="}' else: return '{"retCode": "999","retMessage": "param error","data": ""}'