Example #1
0
    def doGeFuBigPaySdkCallback(self, 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'
                PayHelperV4.callback_ok(orderPlatformId, total_fee, rparam)
                return 'SUCCESS'
            else:
                errinfo = '支付失败'
                PayHelperV4.callback_error(orderPlatformId, errinfo, rparam)
                return 'FAILURE'
        else:
            errinfo = '签名校验失败'
            PayHelperV4.callback_error(orderPlatformId, errinfo, rparam)
            return 'FAILURE'
Example #2
0
    def doMiDaShiPayCallback(cls, rpath):
        # 由于设计到路径和请求方法,验签放到httpgateway里做了,这里只负责发货
        rparam = TyContext.RunHttp.convertArgsToDict()
        TyContext.ftlog.debug('TuYouPayMiDaShi->doMiDaShiPayCallback rparam: ',
                              rparam)
        if 'payitem' in rparam:
            payitem = rparam['payitem']
            appmeta = payitem.split('*')[0]
            platformOrderId = appmeta
        else:
            return cls.getReturnContent(4, 'payitem')

        if 'appmeta' in rparam:
            appmeta = rparam['appmeta']
            if '*' in appmeta:
                appmeta = appmeta.split('*')[1]
            thirdPayType = appmeta
        else:
            return cls.getReturnContent(4, 'appmeta')

        if 'amt' in rparam:
            total_fee = float(rparam['amt'])
        else:
            return cls.getReturnContent(4, 'amt')

        rparam['sub_paytype'] = thirdPayType
        PayHelperV4.callback_ok(platformOrderId, -1, rparam)
        return cls.getReturnContent(0)
Example #3
0
 def doMomoCallback(cls, rpath):
     rparam = TyContext.RunHttp.get_body_content()
     import json
     rparam = json.loads(rparam)
     orderinfo = rparam.get('orderinfo', {})
     statusMsg = rparam.get('statusMsg', '')
     sign = rparam.get('sign')
     signKey = ['cporderid', 'payorderid', 'ordertime', 'status', 'amount', 'currency', 'pname', 'appid', 'cid']
     cporderid = orderinfo.get('cporderid', '')
     config = GameItemConfigure.get_game_channel_configure_by_orderId(cporderid, 'more')
     appkey = config.get('more_appkey', '')
     # 读取默认参数配置
     if not appkey:
         packageName = 'com.sdk.more.default'
         channel = 'kuyuoka'
         appId = '9999'
         config = GameItemConfigure(appId).get_game_channel_configure_by_package('more', packageName, channel)
     appkey = config.get('more_appkey', '')
     signStr = appkey + ''.join(str(orderinfo[k]) for k in signKey)
     from hashlib import md5
     m = md5(signStr)
     if m.hexdigest().lower() != sign:
         PayHelperV4.callback_error(cporderid, '验签失败', rparam)
         return {'returnCode': 0, 'returnMsg': '失败'}
     total_fee = float(orderinfo.get('amount')) / 100
     PayHelperV4.callback_ok(cporderid, total_fee, rparam)
     return {'returnCode': 1, 'returnMsg': ''}
Example #4
0
    def doiToolsPayCallback(self, rpath):
        postData = TyContext.RunHttp.get_body_content()
        TyContext.ftlog.debug('TuYouPayiTools->doiToolsPayCallback postData: ',
                              postData)
        paramslist = postData.split('&')
        params = {}
        for k in paramslist:
            paramdata = k.split('=')
            params[paramdata[0]] = paramdata[1]
        TyContext.ftlog.debug(
            'TuYouPayiTools->doiToolsPayCallback postParams: ', params)

        for k in params.keys():
            params[k] = urllib.unquote(params[k])
        TyContext.ftlog.debug(
            'TuYouPayiTools->doiToolsPayCallback postParams_urldecode: ',
            params)

        pristr = params['notify_data']
        sign = params['sign']
        data = rsa_decrypto_with_publickey(pristr, iTools_pubkey_str, 1)
        TyContext.ftlog.debug(
            'TuYouPayiTools->doiToolsPayCallback iTools callback data: ', data)
        rparam = json.loads(data)
        TyContext.ftlog.debug(
            'TuYouPayiTools->doiToolsPayCallback notify_data: ', rparam)
        try:
            orderPlatformId = rparam['order_id_com']
            amount = rparam['amount']
            account = rparam['account']
            third_orderid = rparam['order_id']
            result = rparam['result']
            user_id = rparam['user_id']
        except:
            TyContext.ftlog.error(
                'TuYouPayiTools->doiToolsPayCallback Get params in iTools callback ERROR!'
            )
            return 'fail'
        if 0 != cmp('success', result):
            TyContext.ftlog.error(
                'TuYouPayiTools->doiToolsPayCallback Charge failed!')
            errormsg = 'user use ' + account + ' charge ' + result
            PayHelperV4.callback_error(orderPlatformId, errormsg, rparam)

        # veriry_result = cls.rsa_verify(data, sign, iTools_pubkey_str)
        veriry_result = _verify_with_publickey_pycrypto(
            data, sign, _iTools_pubkey_py)
        if not veriry_result:
            TyContext.ftlog.error(
                'TuYouPayiTools->doiToolsPayCallback Verify failed! data: %s, sign: %s, iTools_pubkey_str: %s'
                % (data, sign, iTools_pubkey_str))
            return 'fail'

        rparam['third_orderid'] = third_orderid
        PayHelperV4.callback_ok(orderPlatformId, amount, rparam)
        TyContext.ftlog.debug(
            'TuYouPayiTools->doiToolsPayCallback user %s charge % successed! '
            % (user_id, amount))
        return 'success'
Example #5
0
    def doLenovoDanjiCallback(cls, rpath):
        rparam = TyContext.RunHttp.convertArgsToDict()
        TyContext.ftlog.info('doLenovoDanjiCallback->rparam=', rparam)
        try:
            transdata = rparam['transdata']
            verifyData = transdata
            signStr = rparam['sign']
            transdata = json.loads(transdata)
            TyContext.ftlog.debug(
                'TuYouPayLenovoDanji->doLenovoDanjiCallback transdata: ',
                transdata)
            orderPlatformId = transdata['cpprivate']
            appid = transdata['appid']
            total_fee = transdata['money']
            result = transdata['result']
            paytype = transdata['paytype']
            ChargeModel.save_third_pay_order_id(orderPlatformId,
                                                transdata.get('transid'))
        except Exception as e:
            TyContext.ftlog.error(
                'TuYouPayLenovoDanji->doLenovoDanjiCallback ERROR:', e)
            return 'FAILURE'

        if '0' != str(result):
            TyContext.ftlog.error(
                'TuYouPayLenovoDanji->doLenovoDanjiCallback ERROR, sign error !! rparam=',
                rparam, 'sign=', sign)
            PayHelperV4.callback_error(orderPlatformId, '支付失败', transdata)
            return 'FAILURE'

        appkeyconfig = TyContext.Configure.get_global_item_json(
            'lenovodanji_config', {})
        if not appkeyconfig:
            TyContext.ftlog.error(
                'TuYouPayLenovoDanji->doLenovoDanjiCallback Doesn\'t find appkeyconfig by lenovodanji_config'
            )

        for item in appkeyconfig:
            if 0 == cmp(appid, item['appId']):
                lenovodanji_prikey_str = item['appKey']
                break
        else:
            TyContext.ftlog.error(
                'TuYouPayLenovoDanji->doLenovoDanjiCallback Doesn\'t find appkey by appid:',
                appid)
            config = GameItemConfigure.get_game_channel_configure_by_orderId(
                orderPlatformId, 'lenovodj')
            lenovodanji_prikey_str = cls.loadRsaPrivateKey(
                config.get('lenovo_appKey', ""))

        if not cls.verifySign(lenovodanji_prikey_str, verifyData, signStr):
            TyContext.ftlog.error(
                'TuYouPayLenovoDanji->doLenovoDanjiCallback ERROR, sign error')
            return 'FAILURE'

        transdata['sub_paytype'] = paytype
        PayHelperV4.callback_ok(orderPlatformId,
                                float(total_fee) / 100, transdata)
        return 'SUCCESS'
Example #6
0
 def doMeizuPayCallback(cls, rpath):
     rparam = TyContext.RunHttp.convertArgsToDict()
     TyContext.ftlog.info('doMeizuPayCallback rparam', rparam)
     cp_order_id = None
     try:
         cp_order_id = rparam['cp_order_id']
         total_price = float(rparam['total_price'])
         trade_status = rparam['trade_status']
         ChargeModel.save_third_pay_order_id(cp_order_id,
                                             rparam.get('order_id', ''))
     except Exception as e:
         TyContext.ftlog.error('doMeizuCallback param error, exception', e,
                               'cp_order_id', cp_order_id)
         return json.dumps({
             'code': 900000,
             'message': '参数不匹配',
             'redirect': '',
             'value': None
         })
     if not cls._check_sign(rparam):
         TyContext.ftlog.error('TuYouPayMeizu _check_sign failed',
                               cp_order_id)
         return json.dumps({
             'code': 900000,
             'message': '签名错误',
             'redirect': '',
             'value': None
         })
     if trade_status == '3':
         PayHelperV4.callback_ok(cp_order_id, total_price, rparam)
         return json.dumps({
             'code': 200,
             'message': '充值成功',
             'redirect': '',
             'value': None
         })
     elif trade_status == '4':
         PayHelperV4.callback_error(cp_order_id, '订单取消', rparam)
         return json.dumps({
             'code': 900000,
             'message': '',
             'redirect': '',
             'value': None
         })
     elif trade_status == '1' or trade_status == '2':
         return json.dumps({
             'code': 90000,
             'message': '订单处理中',
             'redirect': '',
             'value': None
         })
     elif trade_status == '5':
         return json.dumps({
             'code': 90000,
             'message': '订单异常取消',
             'redirect': '',
             'value': None
         })
Example #7
0
    def doIappayPayCallback(cls, rpath):
        rparam = TyContext.RunHttp.convertArgsToDict()
        transdata = rparam['transdata']
        transdata = json.loads(transdata)
        sign = rparam['sign']
        appid = transdata['appid']
        signtype = rparam['signtype']
        iappayConfig = TyContext.Configure.get_global_item_json(
            'iappay_config', {})
        try:
            pubkey = iappayConfig.get(appid)['pubkey'] if iappayConfig.get(
                appid) else ""
            orderPlatformId = transdata['cporderid']
            total_fee = transdata['money']
            result = transdata['result']
            ChargeModel.save_third_pay_order_id(orderPlatformId,
                                                transdata.get('transid'))
        except Exception as e:
            TyContext.ftlog.error('doIappayPayCallback->ERROR, exception', e,
                                  'rparam', transdata)
            return 'error'
        if not pubkey:
            chargeKey = 'sdk.charge:' + orderPlatformId
            chargeInfo = TyContext.RedisPayData.execute(
                'HGET', chargeKey, 'charge')
            if chargeInfo:
                chargeInfo = TyContext.strutil.loads(chargeInfo,
                                                     decodeutf8=True)
            else:
                return 'failed'
            chargeType = chargeInfo['chargeType']
            sdk = chargeType.split('.')[0]
            config = GameItemConfigure.get_game_channel_configure_by_orderId(
                orderPlatformId, sdk)
            pubkey = config.get('iappay_pubKey')
            if not pubkey:
                TyContext.ftlog.error(
                    'doIappayPayCallback->ERROR,cannot get sdkconfig for',
                    appid)
                return 'failed'
            pubkey = cls.loadRsaPublicKey(pubkey)
        if not cls._verify_sign(rparam, sign, pubkey):
            errinfo = '支付失败'
            PayHelperV4.callback_error(orderPlatformId, errinfo, rparam)
            return 'failed'

        if result != 0:
            errinfo = '支付失败'
            TyContext.ftlog.error(
                'doIappayPayCallback->ERROR, exception, result not 0')
            PayHelperV4.callback_error(orderPlatformId, errinfo, rparam)
            return 'failed'
        PayHelperV4.callback_ok(orderPlatformId, total_fee, rparam)
        return 'success'
Example #8
0
    def doMaopaoPayCallback(cls, rpath):

        rparam = TyContext.RunHttp.convertArgsToDict()

        maopaoInfo = {}
        maopaoInfo['orderId'] = rparam['orderId']
        maopaoInfo['skyId'] = rparam['skyId']
        maopaoInfo['resultCode'] = rparam['resultCode']
        maopaoInfo['payNum'] = rparam['payNum']
        maopaoInfo['cardType'] = rparam['cardType']
        maopaoInfo['realAmount'] = rparam['realAmount']
        maopaoInfo['payTime'] = rparam['payTime']
        maopaoInfo['failure'] = rparam['failure']
        maopaoInfo['signMsg'] = rparam['signMsg']

        rparam['third_orderid'] = maopaoInfo['payNum']
        rparam['chargeType'] = 'maopao'
        maopaoConfig = TyContext.Configure.get_global_item_json(
            'maopao_config', {})
        md5key = maopaoConfig['md5key']

        signParams = rparam['orig_uri']
        signInfo = signParams[signParams.find('?') +
                              1:signParams.find('signMsg') -
                              1] + '&' + 'key' + '=' + md5key

        TyContext.ftlog.info('doMaopaoCallback signInfo', signInfo)

        total_fee = int(maopaoInfo['realAmount']) / 100
        orderPlatformId = maopaoInfo['orderId']

        sign = cls._cal_sign(signInfo)
        TyContext.ftlog.debug('doMaopaoCallback  sign', sign, 'signMsg',
                              maopaoInfo['signMsg'], 'signInfo', signInfo)

        if sign == maopaoInfo['signMsg']:
            if int(maopaoInfo['realAmount']) > 0:
                ChargeModel.save_third_pay_order_id(orderPlatformId,
                                                    maopaoInfo['payNum'])
                PayHelperV4.callback_ok(orderPlatformId, total_fee, rparam)
                TyContext.ftlog.info('doMaopaoCallback->SUCCESSFUL rparam',
                                     rparam)
                return 'result=0'
            else:
                errinfo = '支付失败'
                PayHelperV4.callback_error(orderPlatformId, errinfo, rparam)
                TyContext.ftlog.error('doMaopaoCallback->ERROR, failDesc',
                                      errinfo, 'rparam', rparam)
        else:
            errinfo = '签名校验失败'
            PayHelperV4.callback_error(orderPlatformId, errinfo, rparam)
            TyContext.ftlog.error('doMaopaoCallback->ERROR, failDesc', errinfo,
                                  'rparam', rparam)
        return 'result=0'
Example #9
0
 def doJinliCallback(cls, rpath):
     rparam = TyContext.RunHttp.convertArgsToDict()
     TyContext.ftlog.info('doJinliCallback', rparam)
     try:
         orderPlatformId = rparam['out_order_no']
         total_fee = rparam['deal_price']
     except Exception as e:
         TyContext.ftlog.error('doJinliCallback  ,param err,exception ', e)
         return 'exception in params'
     if not cls._check_sign(rparam):
         TyContext.ftlog.error('doJinliCallback ,check sign error!')
         return 'check sign error!'
     PayHelperV4.callback_ok(orderPlatformId, float(total_fee), rparam)
     return 'success'
Example #10
0
    def doCallback(self, rpath):
        rparams = TyContext.RunHttp.convertArgsToDict()
        order_id = rparams['dealseq']
        TyContext.ftlog.debug('TuYouPayJusdkV4->doCallback,rparams=', rparams)

        if not self.verify_sign(rparams):
            return 'failed'

        notify_data = rparams['notify_data']
        data = rsa_decrypto_with_publickey(notify_data, JUSDK_PUB_KEY, 1)
        TyContext.ftlog.debug('TuYouPayJusdkV4 -> de rsa notify data = ', data)
        notify_dict = dict((l.split('=') for l in data.split('&')))

        if notify_dict.get('dealseq') != rparams.get('dealseq'):
            TyContext.ftlog.debug('TuYouPayJusdkV4 -> dealseq Different')
            return 'failed'

        if int(notify_dict.get('payresult')) != 0:
            TyContext.ftlog.debug('TuYouPayJusdkV4 -> payresult Different')
            return 'failed'

        is_ok = PayHelperV4.callback_ok(order_id, -1, rparams)
        if is_ok:
            return 'success'
        else:
            TyContext.ftlog.debug('TuYouPayJusdkV4 -> not ok')
            return 'failed'
Example #11
0
    def __check_callback(cls, rparam, appKey):
        signQuery = rparam['signature']
        del rparam['signature']

        sk = rparam.keys()
        sk.sort()
        queryStr = ""
        for k in sk:
            queryStr = queryStr + str(k) + '=' + str(rparam[k]) + '&'
        signData = queryStr[:-1]
        TyContext.ftlog.info('doXiaomiCallback->queryStr=', queryStr,
                             'signData=', signData)

        a = hmac.new(appKey, signData, sha1)
        sign = a.digest().encode('hex').upper()
        if signQuery.upper() != sign:
            TyContext.ftlog.info(
                'doXiaomiCallback->ERROR, sign error !! signQuery=', signQuery,
                'sign=', sign)
            return '{"errcode":1525}'

        orderPlatformId = rparam['cpOrderId']

        total_fee = float(rparam['payFee']) / 100
        ChargeModel.save_third_pay_order_id(orderPlatformId,
                                            rparam.get('orderId'))
        isOk = PayHelperV4.callback_ok(orderPlatformId, total_fee, rparam)
        if isOk:
            return '{"errcode":200}'
        else:
            return '{"errcode":1506}'
Example #12
0
 def doCallback(cls, rpath):
     rparam = TyContext.RunHttp.convertArgsToDict()
     TyContext.ftlog.info('TuYouNow callback with: %s' % rparam)
     payNowAppId = rparam['appId']
     borui_paykeys = TyContext.Configure.get_global_item_json('borui_paykeys', {})
     try:
         payNowInfo = borui_paykeys[payNowAppId]
     except KeyError:
         payNowInfo = borui_paykeys
     appSecret = payNowInfo['appSecret']
     ## check signature
     keys = filter(lambda k: k not in ['signType', 'signature', ], rparam.keys())
     keys.sort()
     text = '&'.join(['%s=%s' % (k, rparam[k]) for k in keys])
     text = urllib.unquote(text)  # 转为utf-8编码
     s1 = hashlib.md5(appSecret).hexdigest()
     s2 = hashlib.md5('%s&%s' % (text, s1)).hexdigest()
     if rparam['signature'] != s2:
         TyContext.ftlog.error('TuYouNow->ERROR, sign error !! rparam=', rparam)
         return 'N'
     # do charge
     tradeStatus = rparam['tradeStatus']
     orderPlatformId = rparam['mhtOrderNo']
     if tradeStatus == 'A001':
         if PayHelperV4.callback_ok(orderPlatformId, -1, rparam):
             return 'Y'
     return 'N'
Example #13
0
    def doJiuxiuCallback(cls, rpath):
        rparam = TyContext.RunHttp.convertArgsToDict()
        TyContext.ftlog.info('doJiuxiuCallback start rparam=', rparam)

        try:
            orderPlatformId = rparam['orderPlatformId']
            total_fee = rparam['amount']
            sign = rparam['sign']
            thirdorderid = rparam['orderId']
        except:
            TyContext.ftlog.error('doJiuxiuCallback->ERROR, param error !! rparam=', rparam)
            return 'fail'
        # 签名校验
        if not cls.__verify_sign(rparam, sign):
            TyContext.ftlog.error('TuYouPayJiuxiu.doJiuxiuCallback verify error !!')
            return 'fail'

        rparam['chargeType'] = '9xiu'
        rparam['third_orderid'] = thirdorderid
        total_fee = float(total_fee)
        isOk = PayHelperV4.callback_ok(orderPlatformId, total_fee, rparam)
        if isOk:
            return 'success'
        else:
            return 'fail'
Example #14
0
    def doVivoCallback(cls, rpath):
        rparam = TyContext.RunHttp.convertArgsToDict()

        TyContext.ftlog.info('doVivoCallback->rparam=', rparam)
        orderPlatformId = rparam['storeOrder']

        try:
            appinfoconfig = TyContext.Configure.get_global_item_json(
                'vivo_appkeys', {})
            cpId = rparam['storeId']
            appdata = appinfoconfig[str(cpId)]
            appKey = appdata['cpkey']
        except KeyError:
            config = GameItemConfigure.get_game_channel_configure_by_orderId(
                orderPlatformId, 'vivo')
            appKey = config.get('vivo_cpkey')
        sign = rparam['signature']
        if not cls.__verify_sign(rparam, appKey, sign):
            return 'ERROR'
        total_fee = float(rparam['orderAmount'])
        ChargeModel.save_third_pay_order_id(rparam.get('vivoOrder', ''))
        isOk = PayHelperV4.callback_ok(orderPlatformId, total_fee, rparam)
        if isOk:
            return 'SUCCESS'
        else:
            return 'ERROR'
Example #15
0
    def notifyGameServerDelivery(self, rparam):
        TyContext.ftlog.debug(
            'TuYouPayHuiYuanBaoYue->notifyGameServerDelivery User[%s, mobile:%s, orderid:%s] '
            'subscribe monthly vip!' %
            (rparam['userId'], rparam['mobile'], rparam['platformOrderId']))
        TyContext.RedisUser.execute(rparam['userId'], 'HMSET',
                                    'user:'******'userId'],
                                    'isYouyifuVipUser', '1', 'youyifuVipMsg',
                                    rparam['message'])

        # 这个参数用来告诉游戏服务器,这个商品是一件会员包月商品
        rparam['isYouyifuMonthVip'] = '1'
        PayHelperV4.callback_ok(rparam['platformOrderId'], rparam['total_fee'],
                                rparam)
        self.changeUserInfoStatus('vipuser:'******'mobile'], 'success')
        TyContext.ftlog.info(
            'TuYouPayHuiYuanBaoYue->notifyGameServerDelivery %s has subscribed Monthly VIP.'
            % self.getLogUserInfo(rparam))
Example #16
0
 def doCallback(cls, rpath):
     rparams = TyContext.RunHttp.convertArgsToDict()
     platformOrderId = rparams['extend']
     TyContext.ftlog.debug('TuYouPayLizi->doCallback, rparams=', rparams)
     if not cls.verify_sign(rparams):
         return 'failure'
     isOk = PayHelperV4.callback_ok(platformOrderId, -1, rparams)
     if isOk:
         return 'success'
     else:
         return 'failure'
Example #17
0
    def doPPZhuShouPayCallback(cls, rpath):
        postData = TyContext.RunHttp.get_body_content()
        jsondata = json.loads(postData)
        TyContext.ftlog.info('TuYouPayPPZhuShou->jsondata', jsondata)

        param = eval(''.join(str(jsondata).replace('&', '').split()))

        TyContext.ftlog.debug('TuYouPayPPZhuShou->param after eval()', param)
        # 去除字符串中的回车和换行符
        rparams = param['data']
        orderPlatformId = rparams['orderId']
        config = GameItemConfigure.get_game_channel_configure_by_orderId(
            orderPlatformId, 'ppzhushou')
        if config:
            md5key = config.get('PPZHUSHOU_md5key', "")
        else:
            ppzhushouconfig = TyContext.Configure.get_global_item_json(
                'ppzhushou_config', {})
            md5key = ppzhushouconfig['md5key']
        strSign = cls._cal_sign(rparams, md5key)
        TyContext.ftlog.debug('TuYouPayPPZhuShou->strSign', strSign, 'sign',
                              param['sign'])

        total_fee = float(rparams['amount'])
        rparams['third_orderid'] = rparams['tradeId']
        rparams['chargeType'] = 'ppzhushou'

        if strSign == param['sign']:
            if 'S' == rparams['orderStatus']:
                PayHelperV4.callback_ok(orderPlatformId, total_fee, rparams)
                return 'SUCCESS'
            else:
                errorInfo = '错误订单,等待正确订单......'
                TyContext.ftlog.info('TuYouPayPPZhuShou->errorInfo', errorInfo,
                                     'failedDesc', rparams['failedDesc'])
                return 'SUCCESS'

        else:
            errorInfo = '签名校验错误'
            TyContext.ftlog.error('TuYouPayPPZhuShou->errorInfo', errorInfo)
            return 'FAILURE'
Example #18
0
    def doVivoCallback(cls, rpath):
        rparams = TyContext.RunHttp.convertArgsToDict()
        appId = rparams.get('verdorCode')
        platformOrderId = rparams.get('orderId')
        config = GameItemConfigure.get_game_channel_configure_by_orderId(
            platformOrderId, '16wifi')

        md5key = config.get('16wifi_key')

        signStr = '&'.join(k + '=' + rparams[k] for k in sorted(rparams.keys())
                           if rparams[k] and k != 'sign')

        signStr += '&key=%s' % md5key
        m = md5(signStr)
        if m.hexdigest().upper() != rparams['sign']:
            return {'ReturnCode': 1}
        total_fee = rparams.get('cashAmount')
        ChargeModel.save_third_pay_order_id(platformOrderId,
                                            rparams.get('payCode'))
        PayHelperV4.callback_ok(platformOrderId, total_fee, rparams)
        return {'ReturnCode': 200}
Example #19
0
    def doMomoCallback(cls, rpath):
        rparam = TyContext.RunHttp.convertArgsToDict()
        momo_paykeys = TyContext.Configure.get_global_item_json(
            'momo_paykeys', {})
        TyContext.ftlog.debug('doMomoCallback->rparam=', rparam)
        try:
            orderPlatformId = rparam['app_trade_no']
            trade_no = rparam['trade_no']
            appid = rparam['appid']
            postparams = {}
            postparams['appid'] = appid
            postparams['sign'] = rparam['sign']
            postparams['trade_no'] = trade_no
            postparams['app_secret'] = momo_paykeys[str(appid)]
            response, _ = TyContext.WebPage.webget(cls.checkorder_url,
                                                   postdata_=postparams)
            response = json.loads(response)
            if int(response['ec']) != 0:
                TyContext.ftlog.error(
                    'doMomoCallback->ERROR, check momo order fail, response=',
                    response)
                return 'fail'
        except:
            TyContext.ftlog.exception()
            TyContext.ftlog.error('doMomoCallback->ERROR, rparam=', rparam)
            return 'fail'

        if int(rparam['currency_type']) == 0:
            total_fee = float(rparam['total_fee'])
        else:
            total_fee = float(rparam['total_fee']) / 10
        rparam['third_orderid'] = trade_no
        rparam['chargeType'] = 'momo'
        # channel_type   string 支付渠道 0-苹果 1-支付宝 2-短信 3-陌陌币 4-网页版
        rparam['sub_paytype'] = rparam['channel_type']
        try:
            chargeKey = 'sdk.charge:' + orderPlatformId
            chargeInfo = TyContext.RedisPayData.execute(
                'HGET', chargeKey, 'charge')
            if chargeInfo == None:
                chargeInfo = {}
            else:
                chargeInfo = TyContext.strutil.loads(chargeInfo,
                                                     decodeutf8=True)
            chargeInfo['sub_paytype'] = rparam['channel_type']
            TyContext.RedisPayData.execute('HSET', chargeKey, 'charge',
                                           json.dumps(chargeInfo))
        except:
            TyContext.ftlog.error()

        ChargeModel.save_third_pay_order_id(orderPlatformId, trade_no)
        isOk = PayHelperV4.callback_ok(orderPlatformId, total_fee, rparam)
        return 'success'
Example #20
0
    def do168xCallback(cls, rpath):
        rparam = TyContext.RunHttp.convertArgsToDict()

        signKey = ['game_key', 'game_orderno', 'nonce', 'subject', 'timestamp', 'total_fee']
        platformOrderId = rparam.get('game_orderno')
        signStr = '&'.join(k + '=' + str(rparam.get(k)) for k in signKey)
        config = GameItemConfigure.get_game_channel_configure_by_orderId(platformOrderId)
        if not config:
            appId = '9999'
            sdk = '168x'
            mainChannel = '168x'
            packageName = 'com.sdk.168x.default'
            config = GameItemConfigure(appId).get_game_channel_configure_by_package(sdk, packageName, mainChannel)
        secret = config.get('game_sceret')
        signStr = signStr + '&' + secret
        from hashlib import md5
        m = md5(signStr)
        if m.hexdigest().lower() != rparam.get('signature'):
            return 1
        PayHelperV4.callback_ok(platformOrderId, rparam.get('total_fee'), rparam)
        return 0
Example #21
0
    def doTongBuTuiPayCallback(cls, rpath):
        success = json.dumps({'status': 'success'})
        fail = json.dumps({'status': 'fail'})
        params = TyContext.RunHttp.convertArgsToDict()
        TyContext.ftlog.debug('TuYouPayTongBuTui->doPayTongBuTuiCallback Request Params: ', params)
        rparam = OrderedDict()
        try:
            rparam['source'] = params['source']
            rparam['trade_no'] = params['trade_no']
            rparam['amount'] = params['amount']
            rparam['partner'] = params['partner']
            rparam['paydes'] = params['paydes']
            rparam['debug'] = params['debug']
            rparam['tborder'] = params['tborder']
            rparam['sign'] = params['sign']
        except Exception as e:
            TyContext.ftlog.error('TuYouPayTongBuTui->doPayTongBuTuiCallback Get Params ERROR. ', e)
            return fail
        # appid = 150918, appkey = rBODan#VKXuF8He2B4Olyn@KhXu8RG2q
        # 获取key,根据partner
        keyvalue = TyContext.Configure.get_global_item_json('tongbutui_config', {})  # 获取同步推的key
        for value in keyvalue:
            if 0 == cmp(value['appid'], params['partner']):
                appkey = value['appkey']
                break
        else:
            TyContext.ftlog.error('TuYouPayHaiMaWan->doHaiMaWanPayCallback get appkey ERROR')
            return 'fail'
        rparam['key'] = appkey
        sign = cls.generate_verifysign(rparam)
        if 0 != cmp(sign, rparam['sign']):
            TyContext.ftlog.error('TuYouPayHaiMaWan->doHaiMaWanPayCallback verify sign ERROR.'
                                  'sign: [%s], verify_sign: [%s]' % (rparam['sign'], sign))
            return fail

        # 通知游戏服发货
        rparam['third_orderid'] = rparam['tborder']
        ChargeModel.save_third_pay_order_id(rparam['trade_no'], rparam['tborder'])
        PayHelperV4.callback_ok(rparam['trade_no'], float(rparam['amount']) / 100, rparam)
        return success
Example #22
0
    def doYYgameCallback(cls, rpath):
        rparam = TyContext.RunHttp.convertArgsToDict()
        TyContext.ftlog.info('doYYgameCallback rparam', rparam)
        try:
            total_fee = float(rparam['rmb'])
            subtype = rparam['type']
            account = rparam['account']
            orderid = rparam['orderid']
            orderPlatformId = rparam['cparam']
        except Exception as e:
            TyContext.ftlog.error('doYYgameCallback param error, exception', e)
            return json.dumps({'code': -10, 'data': None})

        if not cls._check_sign(rparam):
            TyContext.ftlog.error('TuYouPayYYGame _check_sign failed')
            return json.dumps({'code': -11, 'data': None})

        rparam['sub_paytype'] = subtype
        PayHelperV4.callback_ok(orderPlatformId, total_fee, rparam)
        cb_response = {'code': 1, 'data': {'orderid': orderid, 'rmb': total_fee
            , 'account': account}}
        TyContext.ftlog.info('doYYgameCallback return', cb_response)
        return json.dumps(cb_response)
Example #23
0
 def doCallback(cls, rpath):
     rparams = TyContext.RunHttp.convertArgsToDict()
     TyContext.ftlog.debug('TuYouPayLudashi->doCallback, rparams=', rparams)
     platformOrderId = rparams['orderId']
     if not cls.check_sign(rparams):
         TyContext.ftlog.error(
             'TuYouPayLudashi.doCallback->ERROR, sign error !! rparam=',
             rparams)
         return {"code": 1, "info": "signature error"}
     isOk = PayHelperV4.callback_ok(platformOrderId, -1, rparams)
     if isOk:
         return {"code": 0, "info": "success"}
     else:
         return {"code": 2, "info": "error"}
Example #24
0
 def doCallback(cls, rpath):
     rparams = TyContext.RunHttp.convertArgsToDict()
     TyContext.ftlog.debug('TuYouPaySougou->doCallback, rparams=', rparams)
     platformOrderId = rparams['appdata']
     amount1 = rparams['amount1']
     if not cls.check_sign(rparams):
         TyContext.ftlog.error(
             'TuYouPaySougou.doCallback->ERROR, sign error !! rparam=',
             rparams)
         return 'ERR_200'
     isOk = PayHelperV4.callback_ok(platformOrderId, -1, rparams)
     if isOk:
         return 'OK'
     else:
         return 'ERR_500'
Example #25
0
    def doUcDjCallback(cls, rpath):
        body = TyContext.RunHttp.get_body_content()
        TyContext.ftlog.debug('TuYouPayUcDj->doUcDjCallback Request data: ',
                              body)
        rparam = TyContext.strutil.loads(body, decodeutf8=True)
        try:
            data = rparam['data']
            orderPlatformId = data['orderId']
            state = data['orderStatus']
            total_fee = data['amount']
            sign = rparam['sign']
            thirdorderid = data['tradeId']
        except:
            TyContext.ftlog.error(
                'TuYouPayUcDj->doUcDjCallback ERROR, param error !! rparam=',
                rparam)
            return 'FAILURE'
        # 签名校验
        if not cls.__verify_sign(data, sign):
            TyContext.ftlog.error(
                'TuYouPayUcDj->doUcDjCallback verify error !!')
            return 'FAILURE'
        # 充值状态校验
        if state != 'S':
            TyContext.ftlog.info(
                'TuYouPayUcDj->doUcDjCallback charge failed. fail reason:',
                data['failedDesc'])
            PayHelperV4.callback_error(orderPlatformId, data['failedDesc'],
                                       rparam)
            return 'SUCCESS'

        data['third_orderid'] = thirdorderid
        total_fee = float(total_fee)
        ChargeModel.save_third_pay_order_id(orderPlatformId, thirdorderid)
        PayHelperV4.callback_ok(orderPlatformId, total_fee, data)
        return 'SUCCESS'
Example #26
0
    def doCallback(self, rpath):
        # convertArgsToDict
        rparams = TyContext.RunHttp.convertArgsToDict()
        order_id = rparams['order_no']
        charge_key = 'sdk.charge:nubia:%s' % order_id
        app_id = TyContext.RedisPayData.execute('HGET', charge_key, 'appId')
        TyContext.ftlog.debug('TuYouPayNubia->doCallback, rparams=', rparams)
        TyContext.ftlog.debug('TuYouPayNubia->doCallback->appId=', app_id)
        if not self.check_sign(rparams, str(app_id)):
            return '{"code":90000,"data":{},"message":"验签失败"}'

        isok = PayHelperV4.callback_ok(order_id, -1, rparams)
        if isok:
            return '{"code":0,"data":{},"message":"成功"}'
        else:
            return '{"code":10000,"data":{},"message":"发货失败"}'
Example #27
0
    def do360payCallback(cls, rpath):
        TyContext.ftlog.debug('do360payCallback start')
        rparam = TyContext.RunHttp.convertArgsToDict()

        try:
            orderPlatformId = rparam['app_order_id']
            appId = orderid.get_appid_frm_order_id(orderPlatformId)
            sign = rparam['sign']
        except:
            TyContext.ftlog.info(
                'do360payCallback->ERROR, param error !! rparam=', rparam)
            return "error"

        clientId = rparam['app_ext1']
        app_key = rparam['app_key']
        client_ids = TyContext.Configure.get_game_item_json(
            appId, 'account.360.client.version', {})
        clientver = ''
        if clientId in client_ids:
            clientver = str(client_ids[clientId])
        client_secret = TyContext.Configure.get_game_item_str(
            appId, 'account.360.client.secret.' + app_key)
        if not client_secret:
            config = GameItemConfigure.get_game_channel_configure_by_orderId(
                orderPlatformId, "360")
            client_secret = config.get('QHOPENSDK_APPSECRET')
        if not client_secret:
            TyContext.ftlog.error(
                'Account360 the appinfo of QIHOO(appKey:%s)  is not found !' %
                app_key)
            return "error"

        # 签名校验
        if not cls.__verify_sign(rparam, client_secret, sign):
            TyContext.ftlog.error(
                'TuyouPay360pay.do360payCallbacksign verify error !!')
            return "error"

        total_fee = float(rparam['amount']) / 100
        ChargeModel.save_third_pay_order_id(orderPlatformId,
                                            rparam.get('order_id', ''))
        isOk = PayHelperV4.callback_ok(orderPlatformId, total_fee, rparam)
        if isOk:
            return "ok"
        else:
            return "error"
Example #28
0
    def callback(cls, rpath):
        try:
            rparam = PayHelperV4.getArgsDict()
            TyContext.ftlog.info(cls.__name__, 'callback->rparam=', rparam)

            orderPlatformId = rparam['mer_trade_code']
            if orderPlatformId.find('-') > 0:
                orderPlatformId = orderPlatformId[0:orderPlatformId.find('-')]

            mer_code = rparam['mer_code']
            bank_pay_flag = rparam['bank_pay_flag']
            sign = rparam['sign']
            total_fee = rparam.get('pay_amount', rparam.get('rec_amount', -1))
            try:
                total_fee = float(total_fee)
            except:
                TyContext.ftlog.error(cls.__name__, 'callback fee error. total_fee', total_fee)
                total_fee = -1

            del rparam['sign']

            vSign = cls.__build_my_sign__(rparam)
            if sign != vSign:
                raise Exception('sign not equal')

            rparam['sign'] = sign

            if mer_code != cls.merchant_code:
                raise Exception('mer_code is not me !!!')

            rparam['third_orderid'] = rparam['gateway_trade_code']
            if bank_pay_flag == 'success':
                chargeType = cls.bank_code2charge_type_dict.get(rparam.get('bank_code', ''), None)
                if chargeType:
                    rparam['chargeType'] = chargeType

                isOk = PayHelperV4.callback_ok(orderPlatformId, total_fee, rparam)
            else:
                bank_pay_flag = bank_pay_flag.decode('utf-8')
                isOk = PayHelperV4.callback_error(orderPlatformId, bank_pay_flag, rparam)
            if isOk:
                return 'success'
        except:
            TyContext.ftlog.exception()

        return 'error'
Example #29
0
    def doCallback(self, rpath):
        rparams = TyContext.RunHttp.convertArgsToDict()
        order_id = rparams['CooperatorOrderSerial']

        TyContext.ftlog.debug('TuYouPayBDGameV4->doCallback, rparams=',
                              rparams)

        if not self.check_sign(rparams):
            # 1成功,不等于1失败
            return self.build_response(rparams, 1001, '验签失败')

        isOk = PayHelperV4.callback_ok(order_id, -1, rparams)

        if isOk:
            return self.build_response(rparams, 1, '发货成功')
        else:
            return self.build_response(rparams, 1002, '发货失败')
Example #30
0
    def doCallback(self, rpath):
        rparams = TyContext.RunHttp.convertArgsToDict()
        order_id = rparams['orderId']
        price_coin = rparams['price']
        config = TyContext.Configure.get_global_item_json('ysdk_keys', {})
        app_id = rparams['ysdk_appid']
        ysdk_model = rparams['ysdk_model']
        ysdk_openId = rparams.get('ysdk_openid', '')
        ChargeModel.save_third_pay_order_id(order_id, 'openId:%s' % ysdk_openId)
        try:
            self.request_url = 'https://' + config['%s_url' % ysdk_model]
            app_key = config[app_id]['%s_appKey' % ysdk_model]
        except:
            config = GameItemConfigure.get_game_channel_configure_by_orderId(order_id, 'ysdk')
            self.request_url = 'https://' + config.get('ysdk_%s_url' % ysdk_model, "")
            app_key = config.get('ysdk_%s_appKey' % ysdk_model, "")
            if not self.request_url or not app_key:
                return 'check sign fail'
        # 验签
        if not self.check_sign(rparams):
            return 'check sign fail'

        # 轮询金币是否到账
        has_balance = self.get_balance_m('/mpay/get_balance_m', app_key, rparams)

        if not has_balance:
            return '充值金币未到账'

        # 尝试扣除金币
        pay_response = self.pay_m('/mpay/pay_m', app_key, rparams)
        if 0 == int(pay_response['ret']) and order_id == pay_response['billno']:
            # 尝试发货
            isOk = PayHelperV4.callback_ok(order_id, -1, rparams)
            if isOk:
                return '发货成功'
            else:
                # 发货失败尝试取消扣费
                return self.cancel_pay_m('/mpay/cancel_pay_m', app_key, rparams)
        elif 1004 == int(pay_response['ret']):
            return '余额不足'
        elif 1018 == int(pay_response['ret']):
            return '登录校验失败'
        else:
            return '扣费失败'