def verify_sign(cls, rparams): sign = rparams['sign'] data = rparams['content'] # wandoujiadanji跟wandoujia使用的是同一个公钥 if rsaVerify(data, sign, 'wandoujia'): return True return False
def doGetUserInfo(cls, params, snsId): uid = params['userId'] session = params['session'] account = params['account'] accountSign = params['accountSign'] TyContext.ftlog.debug('AccountJolo-> getUserInfo', 'account=%s' % account, 'accountSign=%s' % accountSign) if not rsaVerify(account, accountSign, 'jolo'): return False params['snsinfo'] = session return True
def doAliCallback(self, rpath): rparam = PayHelper.getArgsDict() TyContext.ftlog.info('doAliCallback->args=', rparam) sign = rparam['sign'] notify_data = rparam['notify_data'] mock = rparam.get('mock', '') # 签名校验 if not rsaVerify('notify_data=' + notify_data, sign, mock=mock): TyContext.ftlog.error( 'TuyouPayTuyou.doAliCallback rsa verify error !!') return 'error' xmlroot = ElementTree.fromstring(notify_data) trade_status = xmlroot.find('trade_status').text total_fee = float(xmlroot.find('total_fee').text) subject = xmlroot.find('subject').text out_trade_no = xmlroot.find('out_trade_no').text trade_no = xmlroot.find('trade_no').text nodeTime = xmlroot.find('notify_reg_time') if not nodeTime: nodeTime = xmlroot.find('gmt_create') if nodeTime: notify_reg_time = nodeTime.text else: notify_reg_time = 'not know' platformOrderId = out_trade_no notifys = { 'status': trade_status, 'total_fee': total_fee, 'subject': subject, 'out_trade_no': out_trade_no, 'notify_reg_time': notify_reg_time, 'trade_no': trade_no, 'sign': sign, 'notify_data': notify_data, 'chargeType': 'tuyou.ali', 'third_orderid': trade_no } if trade_status == 'TRADE_CLOSED': PayHelper.callback_error(platformOrderId, 'TRADE_CLOSED', notifys) return 'success' if trade_status != 'TRADE_FINISHED': return 'success' isOK = PayHelper.callback_ok(platformOrderId, total_fee, notifys) if isOK: return 'success' else: return 'error'
def verify_sign(self, rparams): sign = rparams.pop('sign') data = [( k, v, ) for k, v in rparams.iteritems()] sorted_data = sorted(data, key=lambda x: x[0], reverse=False) list_data = [ '%s=%s' % (str(k.encode("utf-8")), str(v.encode("utf-8"))) for k, v in sorted_data ] text = '&'.join(list_data) return rsaVerify(text, sign, 'jusdk')
def doCallback(cls, rpath): postData = TyContext.RunHttp.get_body_content() TyContext.ftlog.info("postData", postData) response = urlparse.parse_qs(postData) order = response['order'][0].strip('"') sign = response['sign'][0].strip('"') jsonData = json.loads(order) platformOrderId = jsonData['game_order_id'] if not rsaVerify(order, sign, 'jolo'): TyContext.ftlog.debug('TuYouPayJolo->doCallback', 'order=%s' % order, 'sign=%s' % sign) return 'sign error' isOk = PayHelper.callback_ok(platformOrderId, -1, jsonData) if isOk: return 'success' else: return 'error'
def doAliCallback(self, rpath): rparam = PayHelper.getArgsDict() TyContext.ftlog.info('doAliCallbackNew->args=', rparam) sign = rparam['sign'] notify_data = self.createLinkString(rparam) # TyContext.ftlog.info('doAliCallbackNew->notify_data=', notify_data) # TyContext.ftlog.info('doAliCallbackNew->sign=', sign) # 签名校验 if not rsaVerify(notify_data, sign, 'shediao'): TyContext.ftlog.error( 'TuyouPayTuyou.doAliCallback rsa verify error !!') return 'error' trade_status = rparam['trade_status'] total_fee = rparam['total_fee'] subject = rparam['subject'] out_trade_no = rparam['out_trade_no'] trade_no = rparam['trade_no'] platformOrderId = out_trade_no notifys = { 'status': trade_status, 'total_fee': total_fee, 'subject': subject, 'out_trade_no': out_trade_no, 'trade_no': trade_no, 'sign': sign, 'notify_data': notify_data, 'chargeType': 'shediao.ali', 'third_orderid': trade_no } if trade_status == 'TRADE_CLOSED': PayHelper.callback_error(platformOrderId, 'TRADE_CLOSED', notifys) return 'success' if trade_status != 'TRADE_FINISHED': return 'success' isOK = PayHelper.callback_ok(platformOrderId, total_fee, notifys) if isOK: return 'success' else: return 'error'
def doOppoCallback(self, rpath): rparam = TyContext.RunHttp.convertArgsToDict() orderPlatformId = '' try: notifyId = rparam['notifyId'] orderPlatformId = rparam['partnerOrder'] productName = rparam['productName'] productDesc = rparam['productDesc'] price = rparam['price'] count = rparam['count'] attach = rparam['attach'] sign = rparam['sign'] except: TyContext.ftlog.exception() TyContext.ftlog.info( 'doOppoCallback->ERROR, param error !! rparam=', rparam) return 'result=FAIL&resultMsg=参数错误' baseString = 'notifyId=' + notifyId + '&partnerOrder=' + orderPlatformId + '&productName=' + productName + '&productDesc=' + productDesc + '&price=' + str( price) + '&count=' + str(count) + '&attach=' + attach # 签名校验 if not rsaVerify(baseString, sign, 'oppo'): TyContext.ftlog.error( 'TuyouPayOppo.doOppoCallback rsa verify error !!') return 'result=FAIL&resultMsg=签名验证失败' total_fee = float(price) / 100 isOk = PayHelper.callback_ok(orderPlatformId, total_fee, rparam) if isOk: return 'result=OK&resultMsg=成功' else: return 'result=FAIL&resultMsg=发商品失败' pass
def verifySign(cls, transdata, sign, appKey): TyContext.ftlog.error('TuYouPayWanDouJia-verifySign->transdata=', transdata, 'sign=', sign, 'appKey=', appKey) if rsaVerify(transdata, sign, 'wandoujia'): return True return False
def verify_sign(cls, rparams): sign = rparams['sign'] transdata = rparams['transdata'] return rsaVerify(transdata, sign, 'changba')