Пример #1
0
 public static function sign($params)
 {
     ksort($params);
     $sourceSignString = SignUtil::signString($params, SignUtil::$unSignKeyListForWap);
     LogUtil::log($sourceSignString, LogUtil::OTHER);
     $sha256SourceSignString = hash("sha256", $sourceSignString);
     //LogUtil::log( $sha256SourceSignString, LogUtil::OTHER );
     return RSAUtils::encryptByPrivateKey($sha256SourceSignString);
 }
Пример #2
0
 /**
  * 封装退款form表单
  *
  * @param array $data
  *
  * @return string
  */
 public static function formRefundSumit(array $data)
 {
     list($returnCode, $returnContent) = HttpUtils::http_post_data(self::$_serverRefundUrl, json_encode($data));
     LogUtil::log(date("Y-m-d H:i:s", $_SERVER['REQUEST_TIME']) . PHP_EOL . $returnContent, LogUtil::REFUND);
     $returnContent = json_decode($returnContent, TRUE);
     //执行状态 成功
     if ($returnContent['resultCode'] == 0) {
         $mapResult = $returnContent['resultData'];
         //有返回数据
         if (NULL != $mapResult) {
             $sign = $mapResult["sign"];
             //1.解密签名内容
             $decryptStr = RSAUtils::decryptByPublicKey($sign);
             //2.对data进行sha256摘要加密
             $sha256SourceSignString = hash("sha256", $mapResult["data"]);
             //3.比对结果
             if ($decryptStr == $sha256SourceSignString) {
                 //解密data
                 $decrypData = TDESUtil::decrypt4HexStr(base64_decode(self::$_DES), $mapResult["data"]);
                 //退款结果实体
                 $resultData = json_decode($decrypData, TRUE);
                 //错误消息
                 if (NULL == $resultData) {
                     LogUtil::log(date("Y-m-d H:i:s", $_SERVER['REQUEST_TIME']) . PHP_EOL . $decrypData, LogUtil::ERROR);
                 } else {
                     LogUtil::log(date("Y-m-d H:i:s", $_SERVER['REQUEST_TIME']) . PHP_EOL . var_export($resultData, TRUE), LogUtil::SUCCESS);
                 }
             } else {
                 LogUtil::log(date("Y-m-d H:i:s", $_SERVER['REQUEST_TIME']) . PHP_EOL . "签名失败", LogUtil::ERROR);
             }
         }
     } else {
         //执行退款 失败
         LogUtil::log(date("Y-m-d H:i:s", $_SERVER['REQUEST_TIME']) . PHP_EOL . $returnContent['resultMsg'], LogUtil::ERROR);
     }
 }