Exemple #1
0
    def charge_data(cls, chargeinfo):
        userId = chargeinfo['uid']
        appId = chargeinfo['appId']
        phoneType = TyContext.UserSession.get_phone_type_name(
            chargeinfo['phoneType'])
        price = int(float(chargeinfo['chargeTotal']))
        platformOrderId = chargeinfo['platformOrderId']

        response = cls.__create_order(phoneType, userId, price,
                                      platformOrderId)
        if not response:
            return
        if str(response[0]) != '000':
            TyContext.ftlog.error(
                'TuYouPayEftApi create_order failed for user', userId,
                'orderid', platformOrderId, 'response', response)
            return
        spnumber = str(response[2])
        sms_msg = str(response[3])

        if not ClientRevision(userId).support_type0_smspayinfo:
            payinfo = SmsPayInfo.getSmsPayInfo(1, sms_msg, spnumber)
            chargeinfo['chargeData'] = {'smsPayinfo': payinfo}
            return

        messages = []
        messages.append((spnumber, sms_msg, 0))
        payinfo = SmsPayInfo.build_sms_payinfo(messages)
        SmsPayInfo.fill_in_dialog_text(payinfo, chargeinfo['buttonName'],
                                       chargeinfo['diamondPrice'])
        chargeinfo['chargeData'] = {'smsPayinfo': payinfo}
Exemple #2
0
    def charge_data(cls, chargeinfo):
        TyContext.ftlog.debug('TuYouAiDongManPay charge_data chargeinfo', chargeinfo)

        phonenum = chargeinfo.get('phone', '')
        appId = chargeinfo['appId']
        prodId = chargeinfo['diamondId']
        orderId = chargeinfo['platformOrderId']

        aidongmanConfig = TyContext.Configure.get_global_item_json('aidongmanpay_config', {})
        if aidongmanConfig:
            cls.createorderUrl = aidongmanConfig['createorderUrl']

        aidongmanProdIds = TyContext.Configure.get_global_item_json('aidongmanpay_prodids', {})
        TyContext.ftlog.info('TuYouAiDongManPay charge_data aidongmanProdIds', aidongmanProdIds)

        payCode = aidongmanProdIds[str(appId)]
        # 采短透传方式,短信内容(23位) + 订单信息. callback字段 Extension 返回订单信息
        paymessages = payCode[prodId]['smscodes'] + orderId

        messages = [(payCode[prodId]['smsports'], paymessages, 0)]
        no_hint = chargeinfo.get('nohint', None)
        payinfo = SmsPayInfo.build_sms_payinfo(messages, nohint=no_hint)
        SmsPayInfo.fill_in_dialog_text(
            payinfo, chargeinfo['buttonName'], chargeinfo['diamondPrice'])
        chargeinfo['chargeData'] = {'smsPayinfo': payinfo}
Exemple #3
0
    def charge_data(cls, chargeinfo):
        userId = chargeinfo['uid']
        price = int(float(chargeinfo['chargeTotal']))
        platformOrderId = chargeinfo['platformOrderId']
        shortOrderId = ShortOrderIdMap.get_short_order_id(platformOrderId)

        response, spnumber = cls.__create_order(price, shortOrderId)
        if len(response) == 1:
            TyContext.ftlog.error('TuYouPaySzty create_order failed for user',
                                  userId, 'orderid', platformOrderId,
                                  'response', response)
            return

        sms_msg = response
        if not ClientRevision(userId).support_type0_smspayinfo:
            payinfo = SmsPayInfo.getSmsPayInfo(1, sms_msg, spnumber)
            chargeinfo['chargeData'] = {'smsPayinfo': payinfo}
            return

        messages = [(spnumber, sms_msg, 1000)]
        no_hint = chargeinfo.get('nohint', None)
        payinfo = SmsPayInfo.build_sms_payinfo(messages, nohint=no_hint)
        SmsPayInfo.fill_in_dialog_text(payinfo, chargeinfo['buttonName'],
                                       chargeinfo['diamondPrice'])
        chargeinfo['chargeData'] = {'smsPayinfo': payinfo}
Exemple #4
0
    def charge_data(cls, chargeinfo):
        mdo_config = TyContext.Configure.get_global_item_json(
            'zwmdo_configs', {})
        price = int(float(chargeinfo['chargeTotal']))
        if not str(price) in mdo_config['smscodes']:
            TyContext.ftlog.error(
                'can not find zhuowang smscode in the price=', price)
            return
        orderPlatformId = chargeinfo['platformOrderId']
        spnumber = mdo_config['spnumber']
        smscode = mdo_config['smscodes'][str(price)]
        shortorderid = ShortOrderIdMap.get_short_order_id(orderPlatformId)
        sms_msg = smscode.format(orderId=shortorderid)

        # type是短信支付的方式,1代表的是发一条短信支付
        userId = chargeinfo['uid']
        if not ClientRevision(userId).support_type0_smspayinfo:
            payinfo = SmsPayInfo.getSmsPayInfo(1, sms_msg, spnumber)
        else:
            no_hint = chargeinfo.get('nohint', None)
            messages = []
            messages.append((spnumber, sms_msg, 1000))
            payinfo = SmsPayInfo.build_sms_payinfo(messages, nohint=no_hint)
        SmsPayInfo.fill_in_dialog_text(payinfo, chargeinfo['buttonName'],
                                       chargeinfo['diamondPrice'])
        chargeinfo['chargeData'] = {'smsPayinfo': payinfo}
Exemple #5
0
    def _get_sms_payinfo(cls, chargeinfo, response):
        TyContext.ftlog.info('TuYouPayLinkYunApi _get_sms_payinfo '
                             'response', response, 'chargeinfo', chargeinfo)
        userId = chargeinfo['uid']
        if int(response['resultCode']) != 0:
            TyContext.ftlog.error(
                'TuYouPayLinkYunApi can not get resultCode in the response=',
                response)
            return
        sms_count = 1
        spnumbers = {}
        sms_msgs = {}
        spnumbers[0] = str(response['number'])
        sms_msgs[0] = str(response['command'])
        if response['flag']:
            sms_count = 2
            spnumbers[1] = str(response['number'])
            sms_msgs[1] = str(response['command'])
        if response['confirmContent'] != 'N':
            sms_count = 2
            sms_msgs[1] = str(response['confirmContent'])
            spnumbers[1] = str(response['confirmNumber'])
        if not ClientRevision(userId).support_type0_smspayinfo:
            if sms_count == 2:
                payinfo = SmsPayInfo.getSmsPayInfo(5, sms_msgs[0],
                                                   spnumbers[0], sms_msgs[1],
                                                   spnumbers[1])
            elif sms_count == 1:
                payinfo = SmsPayInfo.getSmsPayInfo(1, sms_msgs[0],
                                                   spnumbers[0])
            chargeinfo['chargeData'] = {'smsPayinfo': payinfo}
            TyContext.ftlog.info(
                'TuYouPayLinkYunApi _get_sms_payinfo chargeData',
                chargeinfo['chargeData'])
            return

        messages = []
        for i in xrange(sms_count):
            messages.append((spnumbers[i], sms_msgs[i], 1000))
        no_hint = chargeinfo.get('nohint', None)
        payinfo = SmsPayInfo.build_sms_payinfo(messages, nohint=no_hint)
        SmsPayInfo.fill_in_dialog_text(payinfo, chargeinfo['buttonName'],
                                       chargeinfo['diamondPrice'])
        chargeinfo['chargeData'] = {'smsPayinfo': payinfo}
        TyContext.ftlog.info('TuYouPayLinkYunApi _get_sms_payinfo chargeData',
                             chargeinfo['chargeData'])
        return
Exemple #6
0
    def charge_data(self, mi):
        chargeinfo = self.get_charge_info(mi)
        TyContext.ftlog.debug('TuYouAiDongManPay charge_data chargeinfo',
                              chargeinfo)

        phonenum = chargeinfo.get('phone', '')
        appId = chargeinfo['appId']
        prodId = chargeinfo['diamondId']
        orderId = chargeinfo['platformOrderId']

        aidongmanConfig = TyContext.Configure.get_global_item_json(
            'aidongmanpay_config', {})
        if aidongmanConfig:
            self.createorderUrl = aidongmanConfig['createorderUrl']

        aidongmanProdIds = TyContext.Configure.get_global_item_json(
            'aidongmanpay_prodids', {})
        TyContext.ftlog.info('TuYouAiDongManPay charge_data aidongmanProdIds',
                             aidongmanProdIds)
        try:
            payCode = aidongmanProdIds[str(appId)]
        except Exception as e:
            mainchannel = chargeinfo['clientId'].split(
                '.')[-2] if chargeinfo['clientId'].split('.') else ""
            config = GameItemConfigure(
                appId).get_game_channel_configure_by_package(
                    'aidongman', chargeinfo['packageName'], mainchannel)
            productConfig = config.get('products')
            if productConfig:
                finalConfig = filter(lambda x: prodId in x.values(),
                                     productConfig)
                finalConfig = finalConfig[0] if finalConfig else []

        # 采短透传方式,短信内容(23位) + 订单信息. callback字段 Extension 返回订单信息
        paymessages = payCode[prodId]['smscodes'] + orderId

        messages = [(payCode[prodId]['smsports'], paymessages, 0)]
        no_hint = chargeinfo.get('nohint', None)
        payinfo = SmsPayInfo.build_sms_payinfo(messages, nohint=no_hint)
        SmsPayInfo.fill_in_dialog_text(payinfo, chargeinfo['buttonName'],
                                       chargeinfo['diamondPrice'])
        chargeinfo['chargeData'] = {'smsPayinfo': payinfo}

        return self.return_mo(0, chargeInfo=chargeinfo)
Exemple #7
0
    def charge_data(cls, chargeinfo):
        TyContext.ftlog.debug('TuyoPayShuzitianyuH5 chare_data ,chargeinfo=', chargeinfo)
        userId = chargeinfo['uid']
        price = int(float(chargeinfo['chargeTotal']))
        platformOrderId = chargeinfo['platformOrderId']
        sms_msg, spnumber = cls._create_order(price, platformOrderId)
        if not sms_msg:
            TyContext.ftlog.error('TuYouPayShuzitianyuH5 create_order failed for user', userId,
                                  'orderid', platformOrderId, 'response', sms_msg)
            return

        if not ClientRevision(userId).support_type0_smspayinfo:
            payinfo = SmsPayInfo.getSmsPayInfo(1, sms_msg, spnumber)
            chargeinfo['chargeData'] = {'smsPayinfo': payinfo}
            return
        messages = [(spnumber, sms_msg, 1000)]
        no_hint = chargeinfo.get('nohint', None)
        payinfo = SmsPayInfo.build_sms_payinfo(messages, nohint=no_hint)
        SmsPayInfo.fill_in_dialog_text(
            payinfo, chargeinfo['buttonName'], chargeinfo['diamondPrice'])
        chargeinfo['chargeData'] = {'smsPayinfo': payinfo}
Exemple #8
0
    def charge_data(cls, chargeinfo):

        userId = chargeinfo['uid']
        price = int(float(chargeinfo['chargeTotal'])) * 100
        platformOrderId = chargeinfo['platformOrderId']
        productDesc = chargeinfo['buttonName']

        appid = chargeinfo['appId']
        productName = '途游斗地主'

        phoneType = TyContext.UserSession.get_phone_type_name(
            chargeinfo['phoneType'])
        gefuconfig = TyContext.Configure.get_global_item_json(
            'gefupay_config', {})
        if gefuconfig:
            cls.createorder_url = gefuconfig[cls.thirdPartyId][phoneType]

        response = cls._create_order(phoneType, userId, price, platformOrderId,
                                     productName, productDesc)
        status = response['code']
        if int(status) != 200:
            TyContext.ftlog.error('TuYouGeFuPay create_order failed for user',
                                  userId, 'reason', response['reason'])
            return

        spnumber, sms_msg = response['sms_port'], response['sms']
        if not ClientRevision(userId).support_type0_smspayinfo:
            payinfo = SmsPayInfo.getSmsPayInfo(1, sms_msg, spnumber)
            chargeinfo['chargeData'] = {'smsPayinfo': payinfo}
            return

        messages = [(spnumber, sms_msg, 0)]
        no_hint = chargeinfo.get('nohint', None)
        payinfo = SmsPayInfo.build_sms_payinfo(messages, nohint=no_hint)
        SmsPayInfo.fill_in_dialog_text(payinfo, chargeinfo['buttonName'],
                                       chargeinfo['diamondPrice'])
        chargeinfo['chargeData'] = {'smsPayinfo': payinfo}
Exemple #9
0
    def charge_data(cls, chargeinfo):
        TyContext.ftlog.info('TuYouPayMingTianDongLiApi->chargeinfo',
                             chargeinfo)

        userId = chargeinfo['uid']
        fee = chargeinfo['chargeTotal']
        orderPlatformId = chargeinfo['platformOrderId']
        ct = datetime.now()
        provider = ''

        phoneType = TyContext.UserSession.get_phone_type_name(
            chargeinfo['phoneType'])
        if phoneType == PHONETYPE_CHINAMOBILE:
            provider = 'YD'
        elif phoneType == PHONETYPE_CHINAUNION:
            provider = 'LT'
        elif phoneType == PHONETYPE_CHINATELECOM:
            provider = 'DX'
        else:
            provider = ''

        mingtiandongliconfig = TyContext.Configure.get_global_item_json(
            'mingtiandongli_config', {})
        cls.createorder_url = mingtiandongliconfig['createorderUrl']
        rparams = OrderedDict()

        rparams['iccid_params'] = TyContext.UserSession.get_session_iccid(
            userId)
        rparams['imei_params'] = TyContext.UserSession.get_session_imei(userId)
        rparams['imsi_params'] = TyContext.UserSession.get_session_imsi(userId)
        rparams['ipAddress'] = TyContext.UserSession.get_session_client_ip(
            userId)
        rparams['channelNum'] = mingtiandongliconfig['channelNum']
        rparams['appID'] = '4944'
        rparams['price_params'] = fee
        rparams['cpParams'] = orderPlatformId
        rparams['provider'] = provider
        rparams['req_date'] = ct.strftime('%Y-%m-%d %H:%M:%S')
        rparams['orderId'] = ''

        # 明天动力,验签暂时关闭.
        # strSign = cls._cal_sign(rparams)
        # rparams['sign'] = strSign
        # TyContext.ftlog.debug('TuYouPayMingTianDongLiApi->rparams', rparams)

        response_msg, _ = TyContext.WebPage.webget(cls.createorder_url,
                                                   rparams,
                                                   method_='GET')
        response = json.loads(response_msg)
        TyContext.ftlog.debug('TuYouPayMingTianDongLiApi->response',
                              str(response).strip("u'"))
        param = eval(str(response).strip("u'"))
        TyContext.ftlog.debug('TuYouPayMingTianDongLiApi->response',
                              str(response), 'param', param)

        if 0 != int(param['result']):
            TyContext.ftlog.error(
                'TuYouPayMingTianDongLiApi->create_order failed for user',
                userId, 'errorCode', param['errorCode'])
            return

        # 当返回的reAccess值为2时,需要重新向服务器发送请求,其他参数为空,运营商标示和上次返回orderId发送即可
        if 2 == int(param['reAccess']):
            secondParams = rparams
            for i in secondParams.key():
                secondParams[i] = ''
            secondParams['provider'] = rparams['provider']
            secondParams['orderId'] = param['orderId']
            response_msg, _ = TyContext.WebPage.webget(cls.createorder_url,
                                                       rparams,
                                                       method_='GET')
            response = json.loads(response_msg)
            param = eval(response)
            TyContext.ftlog.debug('TuYouPayMingTianDongLi->response',
                                  str(response), 'param', param)

        messages = []

        messages.append(
            (param['port1'], param['command1'], int(param['millons'])))

        # 当返回的order为2时,需要发送两条请求.
        if 2 == int(param['order']):
            messages.append((param['port2'], param['command2'], 0))

        no_hint = chargeinfo.get('nohint', None)
        payinfo = SmsPayInfo.build_sms_payinfo(messages, nohint=no_hint)
        SmsPayInfo.fill_in_dialog_text(payinfo, chargeinfo['buttonName'],
                                       chargeinfo['diamondPrice'])
        chargeinfo['chargeData'] = {'smsPayinfo': payinfo}
        TyContext.ftlog.info(
            'TuYouPayMingTianDongLi _get_sms_payinfo chargeData',
            chargeinfo['chargeData'])
        return
Exemple #10
0
    def charge_data(cls, chargeinfo):
        yiconfig = TyContext.Configure.get_global_item_json('yipay_config', {})
        cls.merc_id = str(yiconfig['merc_id'])
        cls.yipay_appid = str(yiconfig['app_id'])
        cls.yipay_key = str(yiconfig['yipay_key'])
        cls.createorder_url = str(yiconfig['createorder_url'])

        userId = chargeinfo['uid']
        appId = chargeinfo['appId']
        phoneType = TyContext.UserSession.get_phone_type_name(
            chargeinfo['phoneType'])
        buttonId = chargeinfo['buttonId']
        price = int(float(chargeinfo['chargeTotal'])) * 100
        platformOrderId = chargeinfo['platformOrderId']
        if buttonId in yiconfig['monthly_prods']:
            is_monthly = '2'
        else:
            is_monthly = '0'
        response = cls._create_order(phoneType, userId, price, platformOrderId,
                                     is_monthly)
        status = response['status']
        msg = create_errmsg.get(status, response['msg'])
        if int(status) != 0:
            TyContext.ftlog.error('TuYouPayYi create_order failed for user',
                                  userId, 'orderid', platformOrderId, 'status',
                                  status, 'msg', msg)
            chargeinfo['chargeData'] = {}
            return
        res = response['res']
        sep = res.get('sms_separator', '@@@')
        sms_count = int(res['sms_count'])
        sms_count = sms_count if sms_count > 1 else 1  # 0/1 is 1
        sms_msg = base64.decodestring(res['sms_msg'])
        spnumber = res['spnumber']
        sms_interval = res.get('sms_interval', 1)
        if not sms_interval:
            sms_interval = 1000
        else:
            sms_interval = int(sms_interval) * 1000
        if sms_count > 1:
            sms_msgs = sms_msg.split(sep)
            spnumbers = spnumber.split(sep)
        else:
            sms_msgs = (sms_msg, )
            spnumbers = (spnumber, )

        if not ClientRevision(userId).support_type0_smspayinfo:
            if sms_count > 2:
                return
            elif sms_count == 2:
                payinfo = SmsPayInfo.getSmsPayInfo(3, sms_msgs[0],
                                                   spnumbers[0], sms_msgs[1],
                                                   spnumbers[1])
            elif sms_count == 1:
                payinfo = SmsPayInfo.getSmsPayInfo(1, sms_msg, spnumber)
            chargeinfo['chargeData'] = {'smsPayinfo': payinfo}
            return

        messages = []
        for i in xrange(sms_count):
            messages.append((spnumbers[i], sms_msgs[i], sms_interval))
        no_hint = chargeinfo.get('nohint', None)
        payinfo = SmsPayInfo.build_sms_payinfo(messages, nohint=no_hint)
        SmsPayInfo.fill_in_dialog_text(payinfo, chargeinfo['buttonName'],
                                       chargeinfo['diamondPrice'])
        chargeinfo['chargeData'] = {'smsPayinfo': payinfo}