From 6b04ca380f5c376b47f6ff07c9f3c6a55e42d074 Mon Sep 17 00:00:00 2001 From: overtrue Date: Mon, 28 Nov 2022 22:18:14 +0800 Subject: [PATCH] Fixed #2622 --- src/Pay/Client.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Pay/Client.php b/src/Pay/Client.php index 1cba2d7dd..ab549c14c 100644 --- a/src/Pay/Client.php +++ b/src/Pay/Client.php @@ -107,10 +107,13 @@ public function request(string $method, string $url, array $options = []): Respo $options['headers']['User-Agent'] = UserAgent::create(); - if ($this->isV3Request($url) && empty($options['headers']['Authorization'])) { + if ($this->isV3Request($url)) { [, $_options] = $this->prepareRequest($method, $url, $options, $this->defaultOptions, true); - $options['headers']['Authorization'] = $this->createSignature($method, $url, $_options); + // 部分签名算法需要使用到 body 中额外的部分,所以交由前置逻辑自行完成 + if (empty($options['headers']['Authorization'])) { + $options['headers']['Authorization'] = $this->createSignature($method, $url, $_options); + } } else { // v2 全部为 xml 请求 if (! empty($options['xml'])) {