Beispiel #1
0
    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'
Beispiel #2
0
    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}'
Beispiel #3
0
    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
Beispiel #4
0
    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 + '"}}'
Beispiel #5
0
    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'
Beispiel #6
0
    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'
Beispiel #7
0
    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'
Beispiel #8
0
    def do360CallbackSNS(self, rpath):

        orderPlatformId = TyContext.RunHttp.getRequestParam('app_order_id', '')
        TyContext.RunMode.get_server_link(orderPlatformId)

        baseinfo = TyContext.RedisPayData.execute(
            'HGET', 'platformOrder:' + str(orderPlatformId), 'PAY_STATE_IDEL')
        baseinfo = json.loads(baseinfo)
        appId = int(baseinfo.get('appId', 0))
        clientId = baseinfo.get('clientId', '')
        client_id, client_secret = self.get_360_app_info(appId, clientId)
        TyContext.ftlog.info('do360CallbackSNS->orderPlatformId=',
                             orderPlatformId, 'appId=', appId, 'clientId=',
                             clientId, 'client_id=', client_id,
                             'client_secret=', client_secret)
        isOK, rparam = self.verify_sign(client_secret)
        if isOK != True:
            TyContext.ftlog.info('do360CallbackSNS->ERROR, sign error !! ')
            return 'error-sign-verify-false'

        from tysdk.entity.pay.pay import TuyouPay
        if rparam.get('gateway_flag') != 'success':
            # 长连接通知,客户端支付失败
            TyContext.ftlog.error(
                'do360CallbackSNS error, charge return error !!!')
            TuyouPay.deliveryChargeError(orderPlatformId, rparam,
                                         u'360SNS支付失败', 1)
            return 'ok'

        trade_status = 'TRADE_FINISHED'
        total_fee = float(rparam.get('amount', -1))
        if total_fee > 0:
            total_fee = total_fee / 100
        isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, total_fee,
                                            trade_status, rparam)
        if isOk:
            return 'ok'
        else:
            return 'error-game-chanrge-exception'
        pass
Beispiel #9
0
    def doMsgYdCallback(self, rpath):
        clientIp = TyContext.RunHttp.get_client_ip()
        TyContext.ftlog.info('TuYouPayMsgYd.doMsgYdCallback in clientIp=', clientIp)
        if not clientIp in ('112.4.3.36'):
            return TuYouPayMsgYd.XML_ERRO % ('')

        xmldata = TyContext.RunHttp.get_body_content()
        # ftlog.info('TuYouPayMsgYd.doMsgYdCallback in xmldata=', xmldata)
        # xmldata = '<?xml version="1.0" encoding="UTF-8"?><request><userId>1246488737</userId><cpServiceId>601810071546</cpServiceId><consumeCode>000071545001</consumeCode><cpParam>1234567890123456</cpParam><hRet>0</hRet><status>1101</status><transIDO>4163657PONE3017B1</transIDO><versionId>100</versionId></request>'
        TyContext.ftlog.info('TuYouPayMsgYd.doMsgYdCallback in xmldata=', xmldata)

        xmlroot = ElementTree.fromstring(xmldata)
        # userId = xmlroot.find('userId').text
        # cpServiceId = xmlroot.find('cpServiceId').text
        # consumeCode = xmlroot.find('consumeCode').text
        orderPlatformId = xmlroot.find('cpParam').text

        hRet = int(xmlroot.find('hRet').text)
        status = int(xmlroot.find('status').text)
        transIDO = xmlroot.find('transIDO').text
        # versionId = xmlroot.find('versionId').text

        TyContext.ftlog.info('TuYouPayMsgYd.doMsgYdCallback in orderPlatformId=', orderPlatformId, 'hRet=', hRet,
                             'status=', status)
        retXml = ''
        from tysdk.entity.pay.pay import TuyouPay
        notifys = {'xml': xmldata}
        if hRet == 0 and status == 1101:
            isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, -1, 'TRADE_FINISHED', notifys)
            if isOk:
                retXml = TuYouPayMsgYd.XML_OK
            else:
                retXml = TuYouPayMsgYd.XML_ERRO
        else:
            TuyouPay.deliveryChargeError(orderPlatformId, notifys, str(hRet) + '|' + str(status), 1)
            retXml = TuYouPayMsgYd.XML_OK

        retXml = retXml % (transIDO)
        return retXml
Beispiel #10
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']

        from tysdk.entity.pay.pay import TuyouPay
        if rparam['orderStatus'] != 'TRADE_SUCCESS':
            # 长连接通知,客户端支付失败
            TyContext.ftlog.error('doXiaomiCallback error, charge return error !!!')
            errorInfo = '小米支付-未知错误'
            TuyouPay.deliveryChargeError(orderPlatformId, rparam, errorInfo, 1)
            return '{"errcode":200}'

        trade_status = 'TRADE_FINISHED'
        total_fee = int(float(rparam['payFee']))
        total_fee = int(total_fee / 100)

        isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, total_fee, trade_status, rparam)
        if isOk:
            return '{"errcode":200}'
        else:
            return '{"errcode":1506}'
Beispiel #11
0
    def doYdjdCallback(self, rpath):
        xmldata = TyContext.RunHttp.get_body_content()
        TyContext.ftlog.debug('TuYouPayYdjd.doYdjdCallback in xmldata=',
                              xmldata)
        ret = None
        status = None
        orderPlatformId = None
        try:
            xmlroot = ElementTree.fromstring(xmldata)
            ret = xmlroot.find('hRet').text
            status = xmlroot.find('status').text
            consumeCode = xmlroot.find('consumeCode').text
            orderPlatformId = xmlroot.find('cpparam').text[2:]
        except:
            pass
        if ret is None or status is None or orderPlatformId is None \
                or consumeCode is None:
            msg = 'missing one of hRet, status, consumeCode or cpparam'
            TyContext.ftlog.error('TuYouPayYdjd.doYdjdCallback:', msg)
            return TuYouPayYdjd.XML_RET % (-1, msg)

        from tysdk.entity.pay.pay import TuyouPay
        notifys = {'xml': xmldata, 'third_prodid': consumeCode}
        if ret != '0' or status != '1800':
            msg = 'ret(%s) is not 0 or status(%s) is not 1800' % (ret, status)
            TyContext.ftlog.error('TuYouPayYdjd.doYdjdCallback:', msg)
            TuyouPay.deliveryChargeError(orderPlatformId, notifys,
                                         str(ret) + '|' + str(status), 1)
            return TuYouPayYdjd.XML_RET % (-1, msg)

        isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, -1,
                                            'TRADE_FINISHED', notifys)
        if isOk:
            return TuYouPayYdjd.XML_RET % (0, 'successful')
        else:
            return TuYouPayYdjd.XML_RET % (-2, 'prod delivery failed')
Beispiel #12
0
    def doCardCallback(self, rpath):
        rparam = TyContext.RunHttp.convertArgsToDict()
        TyContext.ftlog.info('TuYouPayTuyou.doCardCallback->rparam=', rparam)

        version = rparam['version']
        merId = rparam['merId']
        payMoney = rparam['payMoney']
        orderId = rparam['orderId']
        payResult = rparam['payResult']
        privateField = rparam['privateField']
        payDetails = rparam['payDetails']
        md5String = rparam['md5String']
        # signString = rparam['signString']
        cardMoney = None
        if 'cardMoney' in rparam:
            cardMoney = rparam['cardMoney']

        if merId != TuyouPayTuyou.szf_merId:
            TyContext.ftlog.error(
                'TuYouPayTuyou.doCardCallback-> its not my merId ! merId=',
                merId, 'my=', TuyouPayTuyou.szf_merId)
            return 'error'

        combineString = ''
        if cardMoney != None:
            combineString = version + "|" + merId + "|" + payMoney + "|" + cardMoney + "|" + orderId + "|" + payResult + "|" + privateField + "|" + payDetails + "|" + TuyouPayTuyou.szf_privateKey
        else:
            combineString = version + merId + payMoney + orderId + payResult + privateField + payDetails + TuyouPayTuyou.szf_privateKey

        m = hashlib.md5()
        m.update(combineString)
        combineString = m.hexdigest()
        if md5String != combineString:
            TyContext.ftlog.error(
                'TuYouPayTuyou.doCardCallback-> md5 error ! md5String=',
                md5String, 'combineString=', combineString)
            return 'error'

        from tysdk.entity.pay.pay import TuyouPay
        orderPlatformId = privateField
        rparam['payType'] = 'shenzhoufu.card'
        if payResult != '1':
            # 长连接通知,客户端支付失败
            TyContext.ftlog.error(
                'TuYouPayTuyou.doCardCallback error, charge return error !!!')
            errcode = 0
            if 'errcode' in rparam:
                errcode = int(rparam['errcode'])
            errorInfo = ''
            if errcode in TuyouPayTuyou.szf_call_back_code:
                errorInfo = TuyouPayTuyou.szf_call_back_code[errcode]
            else:
                errorInfo = '神州付-未知错误'
            errorInfo = errorInfo.decode('utf-8')
            TuyouPay.deliveryChargeError(orderPlatformId, rparam, errorInfo, 1)
            return orderId

        trade_status = 'TRADE_FINISHED'
        total_fee = int(float(payMoney) / 100)

        isOK = TuyouPay.doBuyChargeCallback(orderPlatformId, total_fee,
                                            trade_status, rparam)
        if isOK:
            return orderId
        else:
            return 'error'
Beispiel #13
0
    def doLianTongCallback(self, rpath):

        xmldata = TyContext.RunHttp.get_body_content()
        # ftlog.info('TuYouPayLianTong.doLianTongCallback in xmldata=', xmldata)
        # xmldata = '<callbackReq><orderid>XXX</orderid><ordertime>XXX</ordertime><cpid>XXX</cpid><appid>XXX</appid><fid>XXX</fid><consumeCode>XXX</consumeCode><payfee>XXX</payfee><payType>XXX</payType><hRet>XXX</hRet><status>XXX</status><signMsg>XXX</signMsg></callbackReq>'
        TyContext.ftlog.info('TuYouPayLianTong.doLianTongCallback in xmldata=',
                             xmldata)

        try:
            xmlroot = ElementTree.fromstring(xmldata)

            orderPlatformId = xmlroot.find('orderid').text

            ordertime = xmlroot.find('ordertime').text
            cpid = xmlroot.find('cpid').text
            #             if xmlroot.find('appid').text:
            #                 appid = xmlroot.find('appid').text
            #             else:
            #                 appid = '905608778920130929155624363800'
            fid = xmlroot.find('fid').text
            consumeCode = xmlroot.find('consumeCode').text
            payfee = int(xmlroot.find('payfee').text)
            payType = int(xmlroot.find('payType').text)
            hRet = int(xmlroot.find('hRet').text)
            status = xmlroot.find('status').text
            signMsg = xmlroot.find('signMsg').text
        except:
            TyContext.ftlog.exception()
            TyContext.ftlog.info(
                'TuYouPayLianTong.doLianTongCallback->ERROR, xmldata error !! xmldata=',
                xmldata)
            return TuYouPayLianTong.XML_ERRO

        # tSign = 'orderid='+orderPlatformId+'&ordertime='+ordertime+'&cpid='+cpid+'&appid='+appid+'&fid='+fid+'&consumeCode='+consumeCode+'&payfee='+str(payfee)+'&payType='+str(payType)+'&hRet='+str(hRet)+'&status='+status+'&Key='+TuYouPayLianTong.appkeys[str(appid)]
        tSign = 'orderid=' + orderPlatformId + '&ordertime=' + ordertime + '&cpid=' + cpid + '&appid=&fid=' + fid + '&consumeCode=' + consumeCode + '&payfee=' + str(
            payfee) + '&payType=' + str(payType) + '&hRet=' + str(
                hRet) + '&status=' + status + '&Key=9813b270ed0288e7c038'
        m = md5()
        m.update(tSign)
        vSign = m.hexdigest()
        if signMsg != vSign:
            TyContext.ftlog.info(
                'TuYouPayLianTong.doLianTongCallback->ERROR, sign error !! sign=',
                signMsg, 'vSign=', vSign)
            return TuYouPayLianTong.XML_ERRO

        TyContext.ftlog.info(
            'TuYouPayLianTong.doLianTongCallback in orderPlatformId=',
            orderPlatformId, 'hRet=', hRet, 'status=', status)
        retXml = ''
        from tysdk.entity.pay.pay import TuyouPay
        notifys = {'xml': xmldata}
        if str(hRet) == '0' and str(status) == '00000':
            isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, -1,
                                                'TRADE_FINISHED', notifys)
            if isOk:
                retXml = TuYouPayLianTong.XML_OK
            else:
                retXml = TuYouPayLianTong.XML_ERRO
        else:
            TuyouPay.deliveryChargeError(orderPlatformId, notifys,
                                         str(hRet) + '|' + str(status), 1)
            retXml = TuYouPayLianTong.XML_OK

        return retXml
Beispiel #14
0
    def doLianTongWCallback(self, rpath):

        # 订单验证处理
        rparam = TyContext.RunHttp.convertArgsToDict()
        TyContext.ftlog.info(
            'TuYouPay360LianTongW.doLianTongWCallback->rparam=', rparam)

        if 'serviceid' in rparam and rparam['serviceid'] == 'validateorderid':
            orderstatus = 0
            appname = ''
            feename = ''
            payfee = ''
            appdeveloper = ''
            gameaccount = ''
            macaddress = ''
            appid = ''
            ipaddress = ''
            serviceid = ''
            channelid = ''
            cpid = ''
            ordertime = ''
            imei = ''
            appversion = ''
            xmldata = TyContext.RunHttp.get_body_content()
            try:
                xmlroot = ElementTree.fromstring(xmldata)

                orderid = xmlroot.find('orderid').text
                signMsg = xmlroot.find('signMsg').text
                if len(orderid) == 24:
                    orderPlatformId = orderid[10:]
                    appInfo = self.__get_order_info__(orderPlatformId)
                    if 'appName' in appInfo and appInfo['appName'] != None:
                        appname = appInfo['appName']
                    if 'feename' in appInfo and appInfo['feename'] != None:
                        feename = appInfo['feename']
                    if 'orderPrice' in appInfo and appInfo[
                            'orderPrice'] != None:
                        payfee = appInfo['orderPrice']
                    if 'appDeveloper' in appInfo and appInfo[
                            'appDeveloper'] != None:
                        appdeveloper = appInfo['appDeveloper']
                    if 'uid' in appInfo and appInfo['uid'] != None:
                        gameaccount = appInfo['uid']
                    if 'mac' in appInfo and appInfo['mac'] != None:
                        macaddress = string.replace(appInfo['mac'], ':', '')
                    if 'woAppId' in appInfo and appInfo['woAppId'] != None:
                        appid = appInfo['woAppId']
                    if 'ip' in appInfo and appInfo['ip'] != None:
                        ipaddress = appInfo['ip']
                    if 'serviceid' in appInfo and appInfo['serviceid'] != None:
                        serviceid = appInfo['serviceid']
                    if 'channelId' in appInfo and appInfo['channelId'] != None:
                        channelid = appInfo['channelId']
                    if 'cpId' in appInfo and appInfo['cpId'] != None:
                        cpid = appInfo['cpId']
                    if 'rtime' in appInfo and appInfo['rtime'] != None:
                        ordertime = appInfo['rtime']
                    if 'imei' in appInfo and appInfo['imei'] != None:
                        imei = appInfo['imei']
                    if 'appversion' in appInfo and appInfo[
                            'appversion'] != None:
                        appversion = appInfo['appversion']
                else:
                    orderstatus = 1
                # 签名验证
                tSign = 'orderid=' + orderid + '&Key=' + TuYouPay360LianTongW.appkeys
                vSign = self.__create_md5_sign__(tSign)
                if signMsg != vSign:
                    TyContext.ftlog.info(
                        'TuYouPay360LianTongW.checkOrder->ERROR, sign error !! sign=',
                        signMsg, 'vSign=', vSign)
                    orderstatus = 1

            except:
                TyContext.ftlog.exception()
                TyContext.ftlog.info(
                    'TuYouPay360LianTongW.doLianTongWCallback->ERROR, xmldata error !! xmldata=',
                    xmldata)
                orderstatus = 1

            return TuYouPay360LianTongW.XML_CHECKORDER_RET % (
                orderstatus, appname, feename, payfee, appdeveloper,
                gameaccount, macaddress, appid, ipaddress, serviceid,
                channelid, cpid, ordertime, imei, appversion)

        # 成功回调处理
        xmldata = TyContext.RunHttp.get_body_content()
        # ftlog.info('TuYouPay360LianTongW.doLianTongWCallback in xmldata=', xmldata)
        # xmldata = '<callbackReq><orderid>XXX</orderid><ordertime>XXX</ordertime><cpid>XXX</cpid><appid>XXX</appid><fid>XXX</fid><consumeCode>XXX</consumeCode><payfee>XXX</payfee><payType>XXX</payType><hRet>XXX</hRet><status>XXX</status><signMsg>XXX</signMsg></callbackReq>'
        TyContext.ftlog.info(
            'TuYouPay360LianTongW.doLianTongWCallback in xmldata=', xmldata)

        try:
            xmlroot = ElementTree.fromstring(xmldata)

            orderid = xmlroot.find('orderid').text
            if len(orderid) == 24:
                orderPlatformId = orderid[10:]
            else:
                orderPlatformId = orderid

            ordertime = xmlroot.find('ordertime').text
            cpid = xmlroot.find('cpid').text

            if xmlroot.find('appid').text:
                appid = xmlroot.find('appid').text
            else:
                # appid = '905608778920130929155624363800'
                appid = ''

            # appid = xmlroot.find('appid').text
            if appid == None:
                appid = ''
            fid = xmlroot.find('fid').text
            consumeCode = xmlroot.find('consumeCode').text
            payfee = int(xmlroot.find('payfee').text)
            payType = int(xmlroot.find('payType').text)
            hRet = int(xmlroot.find('hRet').text)
            status = xmlroot.find('status').text
            signMsg = xmlroot.find('signMsg').text
        except:
            TyContext.ftlog.exception()
            TyContext.ftlog.info(
                'TuYouPay360LianTongW.doLianTongWCallback->ERROR, xmldata error !! xmldata=',
                xmldata)
            return TuYouPay360LianTongW.XML_ERRO

        # tSign = 'orderid='+orderPlatformId+'&ordertime='+ordertime+'&cpid='+cpid+'&appid='+appid+'&fid='+fid+'&consumeCode='+consumeCode+'&payfee='+str(payfee)+'&payType='+str(payType)+'&hRet='+str(hRet)+'&status='+status+'&Key='+TuYouPay360LianTongW.appkeys[str(appid)]
        TyContext.ftlog.debug('TuYouPay360LianTongW.doLianTongWCallback ->',
                              orderid, ordertime, cpid, appid, fid,
                              consumeCode, payfee, payType, hRet, status,
                              TuYouPay360LianTongW.appkeys)
        tSign = 'orderid=' + orderid + '&ordertime=' + ordertime + '&cpid=' + cpid + '&appid=' + appid + \
                '&fid=' + fid + '&consumeCode=' + consumeCode + '&payfee=' + str(payfee) + '&payType=' + str(payType) + \
                '&hRet=' + str(hRet) + '&status=' + status + '&Key=' + TuYouPay360LianTongW.appkeys
        vSign = self.__create_md5_sign__(tSign)

        if signMsg != vSign:
            TyContext.ftlog.info(
                'TuYouPay360LianTongW.doLianTongWCallback->ERROR, sign error !! sign=',
                signMsg, 'vSign=', vSign)
            return TuYouPay360LianTongW.XML_ERRO

        # ftlog.info('TuYouPay360LianTongW.doLianTongWCallback in orderPlatformId=', orderPlatformId, 'hRet=', hRet, 'status=', status)
        retXml = ''
        from tysdk.entity.pay.pay import TuyouPay
        notifys = {'xml': xmldata}
        if str(hRet) == '0' and str(status) == '00000':
            isOk = TuyouPay.doBuyChargeCallback(orderPlatformId, -1,
                                                'TRADE_FINISHED', notifys)
            if isOk:
                retXml = TuYouPay360LianTongW.XML_OK
            else:
                retXml = TuYouPay360LianTongW.XML_ERRO
        else:
            TuyouPay.deliveryChargeError(orderPlatformId, notifys,
                                         str(hRet) + '|' + str(status), 1)
            retXml = TuYouPay360LianTongW.XML_OK

        return retXml