def doGeFuBigPaySdkCallback(cls, rpath): rparam = TyContext.RunHttp.convertArgsToDict() TyContext.ftlog.info('TuYouPayGeFuBigSdk Callback ', rparam) strtransdata = rparam['transdata'] sign = rparam['sign'].replace(' ', '+') params = eval(str(rparam['transdata'])) TyContext.ftlog.info('TuYouPayGeFuBigSdk callback transdata ', params) orderPlatformId = params['cporderid'] total_fee = float(params['money']) if rsacrypto._verify_with_publickey_pycrypto_md5( strtransdata, sign, _aibei_pubkey_py): if 0 == params['result']: rparam['third_orderid'] = params['transid'] rparam['chargeType'] = 'gefubig' PayHelper.callback_ok(orderPlatformId, total_fee, rparam) return 'SUCCESS' else: errinfo = '支付失败' PayHelper.callback_error(orderPlatformId, errinfo, rparam) return 'FAILURE' else: errinfo = '签名校验失败' PayHelper.callback_error(orderPlatformId, errinfo, rparam) return 'FAILURE'
def doZhangYueCallback(cls, rpath): rparam = TyContext.RunHttp.convertArgsToDict() try: appId = rparam['appId'] transData = json.loads(rparam['transData']) orderPlatformId = transData['merOrderId'] price = transData['payAmt'] sign = transData['md5SignValue'] except: TyContext.ftlog.info( 'TuYouPayZhangYueV4 -> ERROR, param error !! rparam=', rparam) return 'error' config = GameItemConfigure.get_game_channel_configure_by_orderId( orderPlatformId, 'zhangyue') paykey = config['zhangyue_md5_key'] # 签名校验 if not cls.__verify_sign(rparam, paykey, sign): TyContext.ftlog.error( 'TuYouPayZhangYue.doZhangYueCallback sign verify error !!') return 'error' total_fee = float(price) rparam['chargeType'] = 'zhangyue' rparam['third_orderid'] = transData['orderId'] isOk = PayHelper.callback_ok(orderPlatformId, total_fee, rparam) TyContext.ftlog.info("TuYouPayZhangYueV4 payhelper callback=", isOk) if isOk: return 'success' else: return 'error'
def doZhangYueCallback(cls, rpath): rparam = TyContext.RunHttp.convertArgsToDict() try: appId = rparam['appId'] transData = json.loads(rparam['transData']) orderPlatformId = transData['merOrderId'] price = transData['payAmt'] sign = transData['md5SignValue'] except: TyContext.ftlog.info( 'doZhangYueCallback->ERROR, param error !! rparam=', rparam) return 'error' paykey_dict = TyContext.Configure.get_global_item_json( 'zhangyue_paykeys', {}) paykey = str(paykey_dict[str(appId)]) # 签名校验 if not cls.__verify_sign(rparam, paykey, sign): TyContext.ftlog.error( 'TuYouPayZhangYue.doZhangYueCallback sign verify error !!') return 'error' total_fee = float(price) rparam['chargeType'] = 'zhangyue' rparam['third_orderid'] = transData['orderId'] isOk = PayHelper.callback_ok(orderPlatformId, total_fee, rparam) if isOk: return 'success' else: return 'error'
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'] appkeyconfig = TyContext.Configure.get_global_item_json('wannew_appkeys', {}) appKey = appkeyconfig[str(appId)] 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 isOk = PayHelper.callback_ok(orderPlatformId, total_fee, rparam) if isOk: return 'Success' else: return 'Fail'
def doCallback1(cls, rpath): datas = cls.__verify_callback__() if not datas: return '{"errorcode ":200024, "callback":1}' TyContext.ftlog.info('TuYouPayYee2.doCallback1 rpath', rpath, 'datas', 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] total_fee = float(datas.get('amount', -1)) / 100 datas['third_orderid'] = datas['yborderid'] if result == 1: isOk = PayHelper.callback_ok(orderPlatformId, total_fee, datas) else: isOk = PayHelper.callback_error(orderPlatformId, str(result), datas) if isOk: return '{"errorcode ":0, "status":1, "callback":1}' else: return '{"errorcode ":200000, "status":1, "callback":1}'
def doHuaWeiCallback(self, rpath): rparam = TyContext.RunHttp.convertArgsToDict() TyContext.ftlog.info('doHuaWeiCallback->rparam=', rparam) try: orderPlatformId = rparam['requestId'] clientId = rparam['extReserved'] huawei_config = TyContext.Configure.get_global_item_json('huawei_config', {}) hwapps = huawei_config.get(clientId, None) isOk = self.__check_ras_code__(hwapps, rparam, False) if isOk: total_fee = 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 = PayHelper.callback_ok(orderPlatformId, total_fee, rparam) if isOk: return '{"result":0}' else: return '{"result":3}' else: return '{"result":1}' except: TyContext.ftlog.exception() return '{"result":94}'
def doPPSCallback(cls, rpath): cb_rsp = {} rparam = TyContext.RunHttp.convertArgsToDict() try: orderPlatformId = rparam['userData'].split(',')[0] appId = rparam['userData'].split(',')[1] price = rparam['money'] sign = rparam['sign'] except: TyContext.ftlog.info('doPPSCallback->ERROR, param error !! rparam=', rparam) cb_rsp['result'] = '-2' cb_rsp['message'] = 'Parameters error' return json.dumps(cb_rsp) paykey_dict = TyContext.Configure.get_global_item_json('pps_paykeys', {}) paykey = str(paykey_dict[str(appId)]) # 签名校验 if not cls.__verify_sign(rparam, paykey, sign): TyContext.ftlog.error('TuYouPayPPS.doPPSCallback sign verify error !!') cb_rsp['result'] = '-1' cb_rsp['message'] = 'Sign error' return json.dumps(cb_rsp) total_fee = float(price) isOk = PayHelper.callback_ok(orderPlatformId, total_fee, rparam) if isOk: cb_rsp['result'] = '0' cb_rsp['message'] = 'success' return json.dumps(cb_rsp) else: cb_rsp['result'] = '-6' cb_rsp['message'] = 'Other errors' return json.dumps(cb_rsp)
def doYouKuCallback(cls, rpath): cb_rsp = {} rparam = TyContext.RunHttp.convertArgsToDict() try: orderPlatformId = rparam['apporderID'] price = rparam['price'] uid = rparam['uid'] sign = rparam['sign'] youku_appId = rparam['passthrough'] 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(youku_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 PayHelper.callback_error(orderPlatformId, 'result(%d) is not 1 or 2' % result, rparam) return json.dumps(cb_rsp) if result == 2: TyContext.ftlog.error( 'doYouKuCallback got partial success result:' 'success_amount is', success_amount) except: pass total_fee = float(price) / 100 rparam['chargeType'] = 'youku' isOk = PayHelper.callback_ok(orderPlatformId, total_fee, 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 doWXpayCallback(cls, rpath): xmldata = TyContext.RunHttp.get_body_content() TyContext.ftlog.info('TuyouPayWXpay.doWXpayCallback in xmldata=', xmldata) xmlroot = ElementTree.fromstring(xmldata) wxappId = xmlroot.find('appid').text openId = xmlroot.find('openid').text rparam = {} for node in xmlroot.iter(): if 'xml' != node.tag: rparam[node.tag] = node.text TyContext.ftlog.debug('TuyouPayWXpay.doWXpayCallback in rparam=', rparam) responseXml = ElementTree.Element('xml') returnCode = ElementTree.SubElement(responseXml, 'return_code') returnMsg = ElementTree.SubElement(responseXml, 'return_msg') try: orderPlatformId = rparam['out_trade_no'] total_fee = float(rparam['total_fee']) / 100 wxconfig = TyContext.Configure.get_global_item_json( 'wx_config', {}) config = wxconfig.get(str(wxappId), None) wxpartnerKey = str(config['partnerKey']) sign = rparam['sign'] except: TyContext.ftlog.info( 'doWXpayCallback->ERROR, param error !! rparam=', rparam) returnCode.text = 'FAIL' returnMsg.text = '参数格式校验错误' responseStr = ElementTree.tostring(responseXml) return responseStr # 签名校验 if not cls.__verify_sign(rparam, wxpartnerKey, sign): TyContext.ftlog.error( 'TuyouPayWXpay.doWXpayCallback verify error !!') returnCode.text = 'FAIL' returnMsg.text = '签名失败' responseStr = ElementTree.tostring(responseXml) return responseStr rparam['third_orderid'] = openId rparam['chargeType'] = 'wxpay' isOk = PayHelper.callback_ok(orderPlatformId, total_fee, rparam) if isOk: returnCode.text = 'SUCCESS' returnMsg.text = 'OK' else: returnCode.text = 'FAIL' returnMsg.text = '发货失败' responseStr = ElementTree.tostring(responseXml) return responseStr
def doUnionPayCallback(cls, rpath): params = TyContext.RunHttp.convertArgsToDict() TyContext.ftlog.debug('TuYouPayYdjd.TuYouPayUnionPay in prams=', '%s' % params) if not cls.validateSign(**params): return 'sign-error' orderId = params['orderId'] isOk = PayHelper.callback_ok(orderId, -1, params) if isOk: return 'ok' else: return 'error'
def handle_order_callback(self, rpath): xmldata = TyContext.RunHttp.get_body_content() TyContext.ftlog.info('PayWeixinPapV4.order_callback in xmldata=', xmldata) xmlroot = ElementTree.fromstring(xmldata) rparams = {} for node in xmlroot.iter(): if 'xml' != node.tag: rparams[node.tag] = node.text # configure wxpap_config = GameItemConfigure(9999).get_game_channel_configure( 'wxpap_config') wxappId = wxpap_config['wxappId'] plan_id = wxpap_config['plan_id'] ## get pay config wxconfig = TyContext.Configure.get_global_item_json('wx_config', {}) config = wxconfig.get(str(wxappId), None) wxappId = str(config['appId']) wxpaySignKey = str(config['paySignKey']) wxappSecret = str(config['appSecret']) wxpartnerId = str(config['partnerId']) wxpartnerKey = str(config['partnerKey']) # response responseXml = ElementTree.Element('xml') returnCode = ElementTree.SubElement(responseXml, 'return_code') returnMsg = ElementTree.SubElement(responseXml, 'return_msg') ### check sign if not self.__verify_sign(rparams, wxpartnerKey, rparams['sign']): TyContext.ftlog.error( 'TuyouPayWXpay.doWXpayCallback verify error !!') returnCode.text = 'FAIL' returnMsg.text = '签名失败' responseStr = ElementTree.tostring(responseXml) return responseStr result_code = rparams['result_code'] out_trade_no = rparams['out_trade_no'] chargeInfo = self.load_order_charge_info(out_trade_no) if result_code == 'SUCCESS': ## huiyuan WeixinHuiyuan(chargeInfo['appId'], chargeInfo['userId']).handle_order(chargeInfo) isOk = PayHelper.callback_ok(out_trade_no, -1, rparams) if isOk: returnCode.text = 'SUCCESS' returnMsg.text = 'OK' return ElementTree.tostring(responseXml) returnCode.text = 'FAIL' returnMsg.text = '发货失败' return ElementTree.tostring(responseXml)
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' platformOrderId = TyContext.RunHttp.getRequestParam('p2_Order') chargeKey = 'sdk.charge:' + platformOrderId chargeInfo = TyContext.RedisPayData.execute('HGET', chargeKey, 'charge') try: import json chargeInfo = json.loads(chargeInfo) rparam['chargeType'] = chargeInfo['chargeType'] except: TyContext.ftlog.exception() rparam['chargeType'] = 'yee.card' rparam['sub_paytype'] = TyContext.RunHttp.getRequestParam( 'p4_FrpId', 'na') 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) errorInfo = u'支付失败,' + TuYouPayYee.code_map.get( status, 'status' + str(status)) PayHelper.callback_error(platformOrderId, errorInfo, rparam) return 'success' total_fee = float(rparam['p3_Amt']) isOK = PayHelper.callback_ok(platformOrderId, total_fee, rparam) if isOK: return 'success' else: return 'error'
def doCallback(cls, rpath): postData = TyContext.RunHttp.get_body_content() TyContext.ftlog.info("postData", postData) response = urlparse.parse_qs(postData) order = response['order'][0].strip('"') sign = response['sign'][0].strip('"') jsonData = json.loads(order) platformOrderId = jsonData['game_order_id'] if not rsaVerify(order, sign, 'jolo'): TyContext.ftlog.debug('TuYouPayJolo->doCallback', 'order=%s' % order, 'sign=%s' % sign) return 'sign error' isOk = PayHelper.callback_ok(platformOrderId, -1, jsonData) if isOk: return 'success' else: return 'error'
def doDuoKuCallback(cls, rpath): TyContext.ftlog.info('doDuoKuCallback start') rparam = TyContext.RunHttp.convertArgsToDict() try: shortOrderPlatformId = rparam['cpdefinepart'] orderPlatformId = ShortOrderIdMap.get_long_order_id( shortOrderPlatformId) appId = rparam['appid'] sign = rparam['sign'] unit = rparam['unit'] amount = rparam['amount'] status = rparam['status'] mobileId = rparam.get('phone', '') except: TyContext.ftlog.info( 'doDuoKuCallback->ERROR, param error !! rparam=', rparam) TyContext.ftlog.exception() return 'failure' if status != 'success': PayHelper.callback_error(orderPlatformId, 'pay fail', rparam) return 'failure' paykey_dict = TyContext.Configure.get_global_item_json( 'duoku_paykeys', {}) paykey = str(paykey_dict[str(appId)]) # 签名校验 if not cls.__verify_sign(rparam, paykey, sign): return 'failure' if unit == 'fen': total_fee = float(amount) / 100 else: total_fee = float(amount) rparam['chargeType'] = 'duoku' rparam['third_orderid'] = rparam['orderid'] PayHelper.set_order_mobile(orderPlatformId, mobileId) isOk = PayHelper.callback_ok(orderPlatformId, total_fee, rparam) if isOk: return 'success' else: return 'failure'
def doHuaWeiCallback(self, rpath): rparam = TyContext.RunHttp.convertArgsToDict() TyContext.ftlog.info('doHuaWeiCallback->rparam=', rparam) try: orderPlatformId = rparam['requestId'] clientId = rparam['extReserved'] huawei_config = TyContext.Configure.get_global_item_json( 'huawei_config', {}) try: hwapps = huawei_config.get[clientId] except KeyError: config = GameItemConfigure.get_game_channel_configure_by_orderId( orderPlatformId, 'huawei') hwapps = { 'pay_ras_pub_key': config.get('huaWei_publicKey'), 'pay_ras_privat_key': config.get('huaWei_privateKey'), } isOk = self.__check_ras_code__(hwapps, rparam, False) if isOk: total_fee = 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 ChargeModel.save_third_pay_order_id(orderPlatformId, rparam.get('orderId', '')) isOk = PayHelper.callback_ok(orderPlatformId, total_fee, rparam) if isOk: return '{"result":0}' else: return '{"result":3}' else: return '{"result":1}' except: TyContext.ftlog.exception() return '{"result":94}'
def doYouKuCallback(cls, rpath): """ qid=50469470&order_amount=10&order_id=youkutest1011&server_id=S1&sign=7439fb6fa5f82104c107648e9ac77d76 sign=md5( qid + order_amount + order_id + server_id + ext + paykey ); :param rpath: :return: """ cb_rsp = {} rparam = TyContext.RunHttp.convertArgsToDict() try: ext = rparam['ext'] extjson = json.loads(ext) ty_order_id = str(extjson.get('ty_order_id')) order_id = rparam['order_id'] order_amount = rparam['order_amount'] qid = rparam['qid'] server_id = rparam['server_id'] sign = rparam['sign'] # youku_appId = rparam['passthrough'] except: TyContext.ftlog.exception() TyContext.ftlog.info( 'doYouKuH5Callback->ERROR, param error !! rparam=', rparam) cb_rsp['status'] = 'failed' cb_rsp['desc'] = '参数错误' # return json.dumps(cb_rsp) return 0 config = TyContext.Configure.get_global_item_json('youkuh5_config', {}) paykey = config.get('payKey') if not paykey: TyContext.ftlog.error('_check_session not paykey ', paykey) return 0 sign_str = qid + order_amount + order_id + server_id + ext + paykey from hashlib import md5 m = md5() m.update(sign_str) my_sign = m.hexdigest() # 签名校验 if my_sign != sign: TyContext.ftlog.error('TuYouPayYouKu sign verify error !!', my_sign, sign) cb_rsp['status'] = 'failed' cb_rsp['desc'] = '签名验证失败' # return json.dumps(cb_rsp) return 0 total_fee = 0 rparam['chargeType'] = 'h5.youku' isOk = PayHelper.callback_ok(ty_order_id, total_fee, rparam) if isOk: cb_rsp['status'] = 'success' cb_rsp['desc'] = '发货成功' # return json.dumps(cb_rsp) return 1 else: cb_rsp['status'] = 'failed' cb_rsp['desc'] = '发货失败' # return json.dumps(cb_rsp) return 0
def doGoogleIABCallback(cls, rpath): action = TyContext.RunHttp.getRequestParam('action', '') appId = TyContext.RunHttp.getRequestParam('appId') clientId = TyContext.RunHttp.getRequestParam('clientId') # google支付需要向客户端返回公钥 publicKey = cls._get_google_public_key(appId, clientId, 'google_publickeys', clientId) TyContext.ftlog.debug('doGoogleIABCallback->action=', action, 'appId=', appId) result = {} if not action or action == '': result['action'] = '' result['state'] = 'error' result['info'] = 'error-action is null' return cls._dict2string(result) elif action == 'getKey': result['action'] = 'getKey' if publicKey == '': result['state'] = 'error' result['info'] = 'error-get publickey failed' return cls._dict2string(result) else: result['state'] = 'success' result['publicKey'] = publicKey result['info'] = 'get publickey success' return cls._dict2string(result) else: platformOrderId = TyContext.RunHttp.getRequestParam( 'platformOrderId', '') result['platformOrderId'] = platformOrderId if action == 'redelivery': result['action'] = 'redilivery' elif action == 'verify': result['action'] = 'verify' isReturn, params = AccountCheck.normal_check(rpath, True) if isReturn: result['state'] = 'error' result['info'] = 'error-accountcheck failed' TyContext.ftlog.error( 'doGoogleIABCallback->accountcheck failed:', params) return cls._dict2string(result) if not platformOrderId or platformOrderId is '': result['state'] = 'error' result['info'] = 'error-null platformOrderId' TyContext.ftlog.error( 'doGoogleIABCallback error platformOrderId is null') return cls._dict2string(result) signData = TyContext.RunHttp.getRequestParam( 'purchaseData', '') signature = TyContext.RunHttp.getRequestParam( 'dataSignature', '') TyContext.ftlog.info( 'TuyouPayGoogleIAB.doGoogleIABCallback->action=', action, 'platformOrderId=', platformOrderId, 'appId=', appId, 'signData=', signData, 'signature=', signature) base64PublicKey = '-----BEGIN PUBLIC KEY-----' + '\n' + publicKey + '\n' + '-----END PUBLIC KEY-----' if False and cls.doGoogleIABCallbackVerify( base64PublicKey, signData, signature) != True: result['state'] = 'error' result['info'] = 'error-verify failed' return cls._dict2string(result) if cls._is_google_transaction_delivered(platformOrderId): result['state'] = 'success' result['info'] = 'transaction-already-delivered' TyContext.ftlog.error( 'doGoogleIABCallback->order is already-delivered:', platformOrderId) return cls._dict2string(result) rparam = PayHelper.getArgsDict() rparam['chargeType'] = 'googleiab' isOk = PayHelper.callback_ok(platformOrderId, -1, rparam) if isOk: cls._mark_google_transaction_as_delivered(platformOrderId) result['state'] = 'success' result['info'] = 'googleiab callback success' return cls._dict2string(result) else: result['state'] = 'error' result['info'] = 'error-delivery' TyContext.ftlog.error('doGoogleIABCallback error delivery') return cls._dict2string(result)
def doIosCallback(cls, rpath): platformOrderId = TyContext.RunHttp.getRequestParam('iosOrderId', '') TyContext.RunMode.get_server_link(platformOrderId) isReturn, params = AccountCheck.normal_check(rpath, True) if isReturn: return params userId = params['userId'] appId = params['appId'] clientId = params['clientId'] appInfo = TyContext.RunHttp.getRequestParam('appInfo', '') isMock = bool(TyContext.RunHttp.getRequestParam('isMock')) receipt = TyContext.RunHttp.getRequestParam('receipt', '') receiptData = {'receiptJsonStr': '{"receipt-data" : "' + receipt + '"}', 'platformOrder': platformOrderId, 'userId': userId} TyContext.ftlog.info('IOS->doIosCallback->userId', userId, 'appId', appId, 'clientId', clientId, 'appInfo', appInfo, 'platformOrderId', platformOrderId, 'receipt', receipt, 'isMock', isMock) rparam = PayHelper.getArgsDict() rparam['chargeType'] = 'tuyooios' rparam['userId'] = params['userId'] rparam['appId'] = params['appId'] rparam['clientId'] = params['clientId'] isSandbox = is_sandbox_receipt(receipt) ret = cls.doIosCallbackVerify(receiptData, isSandbox, isMock) TyContext.ftlog.debug('IOS->doIosCallback->doIosCallbackVerify ret=', ret) if ret != 'ok' and ret != 'uuid_prohibit': PayHelper.callback_error(platformOrderId, ret, rparam) return ret # 如果是被封禁的uuid,不进行发货处理 if ret == 'uuid_prohibit': return 'success' transaction_id = receiptData['original_transaction_id'] rparam['third_orderid'] = transaction_id rparam['third_prodid'] = receiptData.get('product_id', 'na') rparam['isTestOrder'] = receiptData.get('sandbox', False) if cls._is_ios_transaction_delivered(transaction_id): PayHelper.callback_error(platformOrderId, 'error-transaction-already-delivered', rparam) TyContext.ftlog.info('IOS->doIosCallback error-transaction-already-delivered ' 'userId', userId, 'platformOrder', platformOrderId) return 'error-transaction-already-delivered' if not platformOrderId: ret = cls._deliver_missing_order(rparam) if not ret: return 'error-platform-order-missing' else: platformOrderId = ret # 根据商品Id过滤刷单的订单---------------start try: chargeKey = 'sdk.charge:' + platformOrderId chargeInfo = TyContext.RedisPayData.execute('HGET', chargeKey, 'charge') if chargeInfo == None: TyContext.ftlog.info('IOS->doIosCallback error-platformOrderId-not-found ' 'userId', userId, 'platformOrder', platformOrderId) return 'error-platform-order-missing' chargeInfo = TyContext.strutil.loads(chargeInfo, decodeutf8=True) if 'chargeData' in chargeInfo and 'orderIosCode' in chargeInfo['chargeData'] and chargeInfo['chargeData'][ 'orderIosCode'] != rparam['third_prodid']: TyContext.ftlog.info('IOS->doIosCallback error-product_id ' 'userId', userId, 'platformOrder', platformOrderId, 'orderIosCode', chargeInfo['chargeData']['orderIosCode'], 'receipt_product_id', rparam['third_prodid']) return 'error-product_id' except: pass from paytuyooios import TuYouPayMyIos product = TuYouPayMyIos.get_pay_ios_product(appId, rparam['third_prodid'], clientId, 'iosid') if not product: TyContext.ftlog.error('get_pay_ios_product products not found!' ' appId=', appId, 'iosId=', rparam['third_prodid'], 'clientId=', clientId, 'checkIdKey=iosid') return 'error-product_id' # 根据商品Id过滤刷单的订单---------------end isOk = PayHelper.callback_ok(platformOrderId, -1, rparam) if isOk: cls._mark_ios_transaction_as_delivered(transaction_id) try: # 328 & 628 第一次购买后只能使用微信支付 ios_control = TyContext.Configure.get_global_item_json('ios_weinxin_pay_control', {}) if product['tyid'] in ios_control.get('weixin_products', []): wxpay_count = TyContext.RedisUser.execute(userId, 'HGET', 'user:'******'wxpay_flag') if not wxpay_count: wxpay_count = 0 TyContext.RedisUser.execute(userId, 'HSET', 'user:'******'wxpay_flag', int(wxpay_count) + 1) except: TyContext.ftlog.exception() return 'success' else: return 'error-handle-callback'