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}
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}
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}
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}
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
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)
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}
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}
def chargeDataErrorMsg(cls, chargeinfo, shortOrderId, errorCode): errorInfo = TyContext.Configure.get_global_item_json('monthly_vip_subscribe_error_info', {}) sms_msg = '_' + shortOrderId spnumber = '' if not ClientRevision(chargeinfo['uid']).support_type0_smspayinfo: payinfo = SmsPayInfo.getSmsPayInfo(1, sms_msg, spnumber) chargeinfo['chargeData'] = {'smsPayinfo': payinfo} return messages = [(spnumber, sms_msg, 0)] payinfo = {'messages': messages} no_hint = chargeinfo.get('nohint', None) if no_hint: payinfo['nohint'] = no_hint payinfo['text1'] = errorInfo[str(errorCode)] payinfo['text2'] = errorInfo['0'] payinfo['support'] = 'false' monthlyVipParams = TyContext.Configure.get_global_item_json('monthly_vip_params', {}) payinfo['alternativeProdId'] = monthlyVipParams['alternativeProdId'] chargeinfo['chargeData'] = {'smsPayinfo': payinfo}
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
def charge_data(self, mi): chargeinfo = self.get_charge_info(mi) userId, platformOrderId, phoneType = chargeinfo['uid'], chargeinfo[ 'platformOrderId'], chargeinfo['phoneType'] shortOrderId = ShortOrderIdMap.get_short_order_id(platformOrderId) TyContext.ftlog.debug( 'TuYouPayHuiYuanBaoYue->charge_data platformOrderId:[%s] and shortOrderId:[%s]' % (platformOrderId, shortOrderId)) phoneType = TyContext.UserSession.get_phone_type_name(phoneType) TyContext.ftlog.debug( 'TuYouPayHuiYuanBaoYue->charge_data phoneType:[%s].' % phoneType) reportBiParams = {} reportBiParams['platformOrderId'] = platformOrderId reportBiParams['userId'] = userId reportBiParams['appId'] = chargeinfo['appId'] reportBiParams['mobile'] = 'na' reportBiParams['clientId'] = chargeinfo['clientId'] reportBiParams['productId'] = chargeinfo.get( 'diamondId', chargeinfo.get('buttonId', chargeinfo.get('prodId', 'na'))) reportBiParams['payType'] = chargeinfo.get('chargeType', 'na') if 0 == cmp(phoneType, 'chinaMobile'): iccid = TyContext.UserSession.get_session_iccid(userId) citycode = self.getCityCode(iccid) if citycode == 1: self.chargeDataErrorMsg(chargeinfo, shortOrderId, citycode) return self.return_mo(0, chargeInfo=chargeinfo) elif citycode == 2: TyContext.ftlog.info( 'TuYouPayHuiYuanBaoYue->charge_data User client not support Monthly VIP, iccid: [%s]' % iccid) self.reportBi(Order.CLIENT_CANCELED, reportBiParams) self.chargeDataErrorMsg(chargeinfo, shortOrderId, citycode) return self.return_mo(0, chargeInfo=chargeinfo) TyContext.ftlog.debug( 'TuYouPayHuiYuanBaoYue->charge_data citycode:[%s].' % citycode) smsConfigInfo = TyContext.Configure.get_global_item_json( 'chinaMobile_monthly_smsContent', {}) smsInfo = smsConfigInfo.get(str(citycode), None) if not smsInfo: self.chargeDataErrorMsg(chargeinfo, shortOrderId, 2) self.reportBi(Order.CLIENT_CANCELED, reportBiParams) TyContext.ftlog.info( 'TuYouPayHuiYuanBaoYue->charge_data User client not support Monthly VIP, iccid: [%s]' % iccid) return self.return_mo(0, chargeInfo=chargeinfo) TyContext.ftlog.debug( 'TuYouPayHuiYuanBaoYue->charge_data smsInfo is: ', smsInfo) sms_msg, spnumber = smsInfo['subscribe'] autoReplyMsg = smsInfo['auto_reply'] unsub_sms_msg, unsub_spnumber = smsInfo['unsubscribe'] TyContext.ftlog.debug( 'TuYouPayHuiYuanBaoYue->charge_data sms_msg:[%s] and spnumber:[%s] and antuReplyMsg:[%s].' % (sms_msg, spnumber, autoReplyMsg)) TyContext.ftlog.debug( 'TuYouPayHuiYuanBaoYue->charge_data unsub_sms_msg:[%s] and unsub_spnumber:[%s].' % (unsub_sms_msg, unsub_spnumber)) TyContext.RedisPayData.execute( 'SET', 'unsubMonthlySmsInfo:' + str(userId), self.getUnsubscribeSms(unsub_sms_msg, unsub_spnumber)) # 获取自动回复功能的短信监听内容 autoReplyListenContent = TyContext.Configure.get_global_item_json( 'monthly_vip_sms_auto_reply_listen_content', {}) listenContent = autoReplyListenContent[phoneType] messageContent = [autoReplyMsg, ""] messageContent += listenContent monthlyVipParams = TyContext.Configure.get_global_item_json( 'monthly_vip_params', {}) orderIdPhonenum = monthlyVipParams['orderIdPhonenum'] order_sms_msg = '1125ty' + shortOrderId messages = [] message1 = (orderIdPhonenum, order_sms_msg, 0) message2 = (spnumber, sms_msg, 0) message3 = ('', '', -1, messageContent) messages.append(message1) messages.append(message2) messages.append(message3) if not ClientRevision(userId).support_type0_smspayinfo: payinfo = SmsPayInfo.getSmsPayInfo(5, order_sms_msg, orderIdPhonenum, sms_msg, spnumber) chargeinfo['chargeData'] = {'smsPayinfo': payinfo} return self.return_mo(0, chargeInfo=chargeinfo) no_hint = chargeinfo.get('nohint', None) payinfo = {'messages': messages} payinfo['support'] = 'true' if no_hint: payinfo['nohint'] = no_hint SmsPayInfo.fill_in_dialog_text(payinfo, chargeinfo['buttonName'], chargeinfo['diamondPrice']) chargeinfo['chargeData'] = {'smsPayinfo': payinfo} return self.return_mo(0, chargeInfo=chargeinfo) elif 0 == cmp(phoneType, 'chinaUnion'): iccid = TyContext.UserSession.get_session_iccid(userId) citycode = self.getChinaUnionCityCode(iccid) if citycode == 1: self.chargeDataErrorMsg(chargeinfo, shortOrderId, citycode) return self.return_mo(0, chargeInfo=chargeinfo) elif citycode == 2: self.reportBi(Order.CLIENT_CANCELED, reportBiParams) TyContext.ftlog.info( 'TuYouPayHuiYuanBaoYue->charge_data User client not support Monthly VIP, iccid [%s]' % iccid) self.chargeDataErrorMsg(chargeinfo, shortOrderId, citycode) return self.return_mo(0, chargeInfo=chargeinfo) TyContext.ftlog.debug( 'TuYouPayHuiYuanBaoYue->charge_data citycode:[%s].' % citycode) smsConfigInfo = TyContext.Configure.get_global_item_json( 'chinaUnion_monthly_smsContent', {}) smsInfo = smsConfigInfo.get(str(citycode), None) if not smsInfo: self.chargeDataErrorMsg(chargeinfo, shortOrderId, 2) self.reportBi(Order.CLIENT_CANCELED, reportBiParams) TyContext.ftlog.info( 'TuYouPayHuiYuanBaoYue->charge_data User client not support Monthly VIP, iccid: [%s]' % iccid) return self.return_mo(0, chargeInfo=chargeinfo) TyContext.ftlog.debug( 'TuYouPayHuiYuanBaoYue->charge_data smsInfo is: ', smsInfo) sms_msg, spnumber = smsInfo['subscribe'] autoReplyMsg = smsInfo['auto_reply'] unsub_sms_msg, unsub_spnumber = smsInfo['unsubscribe'] TyContext.ftlog.debug( 'TuYouPayHuiYuanBaoYue->charge_data sms_msg:[%s] and spnumber:[%s] and antuReplyMsg:[%s].' % (sms_msg, spnumber, autoReplyMsg)) # 获取自动回复功能的短信监听内容 autoReplyListenContent = TyContext.Configure.get_global_item_json( 'monthly_vip_sms_auto_reply_listen_content', {}) listenContent = autoReplyListenContent[phoneType] messageContent = [autoReplyMsg, ""] messageContent += listenContent sms_msg = sms_msg + '_' + shortOrderId messages = [] message1 = (spnumber, sms_msg, 0) message2 = ('', '', -1, messageContent) messages.append(message1) messages.append(message2) elif 0 == cmp(phoneType, 'chinaTelecom'): smsConfigInfo = TyContext.Configure.get_global_item_json( 'chinaTelecom_monthly_smsContent', {}) sms_msg, spnumber = smsConfigInfo['subscribe'] autoReplyMsg = smsConfigInfo['auto_reply'] unsub_sms_msg, unsub_spnumber = smsConfigInfo['unsubscribe'] TyContext.ftlog.debug( 'TuYouPayHuiYuanBaoYue->charge_data sms_msg:[%s] and spnumber:[%s] and antuReplyMsg:[%s].' % (sms_msg, spnumber, autoReplyMsg)) # 获取自动回复功能的短信监听内容 autoReplyListenContent = TyContext.Configure.get_global_item_json( 'monthly_vip_sms_auto_reply_listen_content', {}) listenContent = autoReplyListenContent[phoneType] messageContent = [autoReplyMsg, ""] messageContent += listenContent sms_msg = sms_msg + '_' + shortOrderId messages = [] message1 = (spnumber, sms_msg, 0) message2 = ('', '', -1, messageContent) messages.append(message1) messages.append(message2) else: self.chargeDataErrorMsg(chargeinfo, shortOrderId, 1) return self.return_mo(0, chargeInfo=chargeinfo) # 联通和电信会走该逻辑 TyContext.ftlog.debug( 'TuYouPayHuiYuanBaoYue->charge_data unsub_sms_msg:[%s] and unsub_spnumber:[%s].' % (unsub_sms_msg, unsub_spnumber)) TyContext.RedisPayData.execute( 'SET', 'unsubMonthlySmsInfo:' + str(userId), self.getUnsubscribeSms(unsub_sms_msg, unsub_spnumber)) if not ClientRevision(userId).support_type0_smspayinfo: payinfo = SmsPayInfo.getSmsPayInfo(1, sms_msg, spnumber) chargeinfo['chargeData'] = {'smsPayinfo': payinfo} return self.return_mo(0, chargeInfo=chargeinfo) no_hint = chargeinfo.get('nohint', None) payinfo = {'messages': messages} payinfo['support'] = 'true' if no_hint: payinfo['nohint'] = no_hint SmsPayInfo.fill_in_dialog_text(payinfo, chargeinfo['buttonName'], chargeinfo['diamondPrice']) chargeinfo['chargeData'] = {'smsPayinfo': payinfo} return self.return_mo(0, chargeInfo=chargeinfo)
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}