mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2026-06-07 12:38:11 +08:00
fix: 更新微信配置文件
This commit is contained in:
parent
3a9f6e88b6
commit
3572908808
@ -171,6 +171,12 @@ class Config extends Controller
|
||||
if ($this->request->isPost()) {
|
||||
$local = LocalStorage::instance();
|
||||
$wechat = $this->request->post('wechat');
|
||||
if (empty($wechat['mch_pay_sid'])) {
|
||||
$this->error('微信支付公钥序号为空!');
|
||||
}
|
||||
if (empty($wechat['mch_ssl_pay']) || !$local->has($wechat['mch_ssl_pay'], true)) {
|
||||
$this->error('微信支付公钥不能为空!');
|
||||
}
|
||||
// PEM 证书模式处理
|
||||
if ($wechat['mch_ssl_type'] === 'pem') {
|
||||
if (empty($wechat['mch_ssl_key']) || !$local->has($wechat['mch_ssl_key'], true)) {
|
||||
@ -186,8 +192,8 @@ class Config extends Controller
|
||||
$this->error('商户证书 P12 不能为空!');
|
||||
}
|
||||
if (openssl_pkcs12_read($local->get($wechat['mch_ssl_p12'], true), $certs, $wechat['mch_id'])) {
|
||||
$name1 = "wxpay/{$wechat['mch_id']}_cer.pem";
|
||||
$name2 = "wxpay/{$wechat['mch_id']}_key.pem";
|
||||
$name1 = sprintf("wxpay/%s_%s_cer.pem", $wechat['mch_id'], md5($certs['cert']));
|
||||
$name2 = sprintf("wxpay/%s_%s_key.pem", $wechat['mch_id'], md5($certs['pkey']));
|
||||
$wechat['mch_ssl_cer'] = $local->set($name1, $certs['cert'], true)['url'];
|
||||
$wechat['mch_ssl_key'] = $local->set($name2, $certs['pkey'], true)['url'];
|
||||
$wechat['mch_ssl_type'] = 'pem';
|
||||
@ -195,22 +201,19 @@ class Config extends Controller
|
||||
$this->error('商户账号与 P12 证书不匹配!');
|
||||
}
|
||||
}
|
||||
if (empty($wechat['mch_ssl_pay']) || !$local->has($wechat['mch_ssl_pay'], true)) {
|
||||
$this->error('微信支付公钥不能为空!');
|
||||
}
|
||||
// 记录文本格式参数,兼容分布式部署
|
||||
sysdata('plugin.wechat.payment', [
|
||||
'appid' => WechatService::getAppid(),
|
||||
'mch_id' => $wechat['mch_id'],
|
||||
'mch_key' => $wechat['mch_key'],
|
||||
'mch_v3_key' => $wechat['mch_v3_key'],
|
||||
'ssl_pay_id' => $wechat['mch_v3_payid'] ?? '',
|
||||
'mch_ssl_cer' => $wechat['mch_ssl_cer'],
|
||||
'mch_ssl_key' => $wechat['mch_ssl_key'],
|
||||
'mch_ssl_pay' => $wechat['mch_ssl_pay'],
|
||||
'mch_pay_sid' => $wechat['mch_pay_sid'] ?? '',
|
||||
'ssl_pay_text' => $local->get($wechat['mch_ssl_pay'], true),
|
||||
'ssl_cer_text' => $local->get($wechat['mch_ssl_cer'], true),
|
||||
'ssl_key_text' => $local->get($wechat['mch_ssl_key'], true),
|
||||
'ssl_pay_text' => $local->get($wechat['mch_ssl_pay'], true),
|
||||
]);
|
||||
// 同步更新证书内容
|
||||
WechatService::withWxpayCert(['mch_id' => $wechat['mch_id']]);
|
||||
|
||||
@ -241,7 +241,7 @@ class WechatService extends Service
|
||||
$options['ssl_key'] = $sslKey;
|
||||
$options['cert_public'] = $sslCer;
|
||||
$options['cert_private'] = $sslKey;
|
||||
$options['mp_cert_serial'] = $data['ssl_pay_id'] ?? '';
|
||||
$options['mp_cert_serial'] = $data['mch_pay_sid'] ?? '';
|
||||
$options['mp_cert_content'] = $data['ssl_pay_text'] ?? '';
|
||||
return $options;
|
||||
}
|
||||
|
||||
@ -36,8 +36,8 @@
|
||||
<div class="hr-line-dashed"></div>
|
||||
|
||||
<label class="layui-form-item relative block">
|
||||
<span class="help-label"><b>微信 V3 支付公钥ID</b>MCH_V3_PAYID</span>
|
||||
<input name="wechat.mch_v3_payid" vali-name="微信商户V3支付公钥ID" placeholder="请输入微信商户V3支付公钥ID(必填)" maxlength="45" pattern="PUB_KEY_ID_.{34}" required value="{$data.mch_v3_payid|default=''}" class="layui-input">
|
||||
<span class="help-label"><b>微信 V3 支付公钥ID</b>ssl_pay_unid</span>
|
||||
<input name="wechat.mch_pay_sid" vali-name="微信商户V3支付公钥ID" placeholder="请输入微信商户V3支付公钥ID(必填)" maxlength="45" pattern="PUB_KEY_ID_.{34}" required value="{$data.mch_pay_sid|default=''}" class="layui-input">
|
||||
<span class="help-block">微信商户 V3 支付证书ID,需要在微信商户平台操作设置操作密码并获取商户接口密钥</span>
|
||||
</label>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user