Commit 035e2785 by 郑建康(PHP)

优化代付通道解密方法

1 parent 78531dd1
...@@ -51,7 +51,14 @@ class HsqTransferNotify extends NotifyStrategy ...@@ -51,7 +51,14 @@ class HsqTransferNotify extends NotifyStrategy
$tmp2 = explode("=",$val); $tmp2 = explode("=",$val);
$result_data[$tmp2[0]] = $tmp2[1]; $result_data[$tmp2[0]] = $tmp2[1];
} }
return $result_data; if (empty($this->config->publicKey)) return false;
$publicKey = $this->config->publicKey;
$retData = $result_data['data_content'];
//解密
$decrypt = BaoFooRsaUtil::decryptByCERFile($retData, $publicKey);
$data_content = DataParser::toArray($decrypt);
$result = $data_content['trans_reqDatas']['trans_reqData'] ?? '';
return $result;
} }
/** /**
...@@ -75,22 +82,7 @@ class HsqTransferNotify extends NotifyStrategy ...@@ -75,22 +82,7 @@ class HsqTransferNotify extends NotifyStrategy
*/ */
protected function verifySign(array $retData) protected function verifySign(array $retData)
{ {
if (empty($this->config->publicKey)) return false; return true;
$publicKey = $this->config->publicKey;
$retData = $retData['data_content'];
//解密
$decrypt = BaoFooRsaUtil::decryptByCERFile($retData, $publicKey);
$data_content = DataParser::toArray($decrypt);
$result = $data_content['trans_reqDatas']['trans_reqData'] ?? '';
if($result)
{
//验签成功
return $result;
}
else{
return false;
}
} }
/** /**
......
...@@ -51,7 +51,7 @@ abstract class NotifyStrategy ...@@ -51,7 +51,7 @@ abstract class NotifyStrategy
} }
// 回调商户的业务逻辑 // 回调商户的业务逻辑
$flag = $this->callback($notify, $checkRet); $flag = $this->callback($notify, $notifyData);
if ($flag) { if ($flag) {
$msg = 'OK'; $msg = 'OK';
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!