From 6adf4c91203482f7bca553c96e0e2059f5d3e23c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Tue, 4 Mar 2025 14:02:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/service/WechatService.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/plugin/think-plugs-wechat/src/service/WechatService.php b/plugin/think-plugs-wechat/src/service/WechatService.php index ae5797811..873d2e42a 100644 --- a/plugin/think-plugs-wechat/src/service/WechatService.php +++ b/plugin/think-plugs-wechat/src/service/WechatService.php @@ -189,9 +189,6 @@ class WechatService extends Service 'token' => sysconf('wechat.token'), 'appsecret' => sysconf('wechat.appsecret'), 'encodingaeskey' => sysconf('wechat.encodingaeskey'), - 'mch_id' => sysconf('wechat.mch_id'), - 'mch_key' => sysconf('wechat.mch_key'), - 'mch_v3_key' => sysconf('wechat.mch_v3_key'), 'cache_path' => syspath('runtime/wechat'), ]); } @@ -210,11 +207,7 @@ class WechatService extends Service 'appsecret' => $wxapp['appkey'] ?? '', 'cache_path' => syspath('runtime/wechat'), ]; - return $ispay ? static::withWxpayCert(array_merge([ - 'mch_id' => sysconf('wechat.mch_id'), - 'mch_key' => sysconf('wechat.mch_key'), - 'mch_v3_key' => sysconf('wechat.mch_v3_key'), - ], $config)) : $config; + return $ispay ? static::withWxpayCert($config) : $config; } /** @@ -227,8 +220,8 @@ class WechatService extends Service { // 文本模式主要是为了解决分布式部署 $data = sysdata('plugin.wechat.payment'); - $name1 = sprintf("wxpay/%s_%s_cer.pem", $options['mch_id'], md5($data['ssl_cer_text'])); - $name2 = sprintf("wxpay/%s_%s_key.pem", $options['mch_id'], md5($data['ssl_key_text'])); + $name1 = sprintf("wxpay/%s_%s_cer.pem", $data['mch_id'], md5($data['ssl_cer_text'])); + $name2 = sprintf("wxpay/%s_%s_key.pem", $data['mch_id'], md5($data['ssl_key_text'])); $local = LocalStorage::instance(); if ($local->has($name1, true) && $local->has($name2, true)) { $sslCer = $local->path($name1, true); @@ -237,6 +230,9 @@ class WechatService extends Service $sslCer = $local->set($name1, $data['ssl_cer_text'], true)['file']; $sslKey = $local->set($name2, $data['ssl_key_text'], true)['file']; } + $options['mch_id'] = $data['mch_id']; + $options['mch_key'] = $data['mch_key']; + $options['mch_v3_key'] = $data['mch_v3_key']; $options['ssl_cer'] = $sslCer; $options['ssl_key'] = $sslKey; $options['cert_public'] = $sslCer;