增加 无 headers 处理

This commit is contained in:
邹景立 2023-05-04 22:58:15 +08:00
parent c806ba514a
commit 685617267f

View File

@ -175,9 +175,12 @@ abstract class BasicWePay
} }
} }
try { try {
if (empty($headers)) {
return $isjson ? json_decode($content, true) : $content;
}
$string = join("\n", [$headers['timestamp'], $headers['nonce'], $content, '']); $string = join("\n", [$headers['timestamp'], $headers['nonce'], $content, '']);
if (!$this->signVerify($string, $headers['signature'], $headers['serial'])) { if (!$this->signVerify($string, $headers['signature'], $headers['serial'])) {
throw new InvalidResponseException("验证响应签名失败"); throw new InvalidResponseException('验证响应签名失败');
} }
} catch (\Exception $exception) { } catch (\Exception $exception) {
throw new InvalidResponseException($exception->getMessage(), $exception->getCode()); throw new InvalidResponseException($exception->getMessage(), $exception->getCode());