注意:根据此贴修改完之后重启下守护进程
1.增加两个支付的配置,复制下方sql语句,在数据库中执行
INSERT INTO `test_pro30_crmeb`.`eb_system_config` (`id`, `is_store`, `menu_name`, `type`, `input_type`, `config_tab_id`, `parameter`, `upload_type`, `required`, `width`, `high`, `value`, `info`, `desc`, `sort`, `status`) VALUES (null, 0, 'v3_pay_public_pem', 'upload', '', 4, '', 3, '', 0, 0, '\"\"', 'v3支付公钥证书', 'v3支付公钥证书,使用新版本支付公钥上传此证书', 0, 1);
INSERT INTO `test_pro30_crmeb`.`eb_system_config` (`id`, `is_store`, `menu_name`, `type`, `input_type`, `config_tab_id`, `parameter`, `upload_type`, `required`, `width`, `high`, `value`, `info`, `desc`, `sort`, `status`) VALUES (null, 0, 'v3_pay_public_key', 'text', 'input', 4, '', 1, '', 100, 0, '\"\"', 'v3支付公钥', 'v3支付公钥,新版本使用公钥请填写', 0, 1);
2,文件地址:app/services/system/config/SystemConfigServices.php
找到方法:shopPayFormBuild()替换此方法
public function shopPayFormBuild()
{
$build = new Build();
$build->url('setting/config/save_basics');
$data = $this->getConfigAllField([
'pay_weixin_open', 'pay_weixin_mchid', 'pay_weixin_key', 'paydir',
'balance_func_status', 'yue_pay_status', 'offline_pay_status',
'offline_pay_status', 'ali_pay_status', 'ali_pay_appid', 'alipay_public_key', 'alipay_merchant_private_key',
'pay_weixin_client_cert', 'pay_wechat_type', 'pay_weixin_serial_no', 'v3_pay_weixin_key', 'pay_weixin_client_key', 'pay_routine_open', 'pay_routine_mchid','v3_pay_public_pem','v3_pay_public_key'
]);
$site_url = sys_config('site_url', '');
$build->rule([
Build::tabs()->option('微信支付', [
Build::alert('登录微信商户(地址:https://pay.weixin.qq.com,支付授权目录、回调链接:' . $site_url . '; http,https最好都配置),帮助文档地址:https://doc.crmeb.com/web/pro/crmebprov2/1203', Alert::WARNING)->showIcon(true),
Build::switch('pay_weixin_open', $data['pay_weixin_open']['info'], (int)$data['pay_weixin_open']['value'])->control(1, [
Build::input('pay_weixin_mchid', $data['pay_weixin_mchid']['info'], $data['pay_weixin_mchid']['value'])->info($data['pay_weixin_mchid']['desc']),
Build::radio('pay_wechat_type', $data['pay_wechat_type']['info'], (int)$data['pay_wechat_type']['value'])->control(1, [
Build::input('pay_weixin_serial_no', $data['pay_weixin_serial_no']['info'], $data['pay_weixin_serial_no']['value'])->info($data['pay_weixin_serial_no']['desc']),
Build::input('v3_pay_weixin_key', $data['v3_pay_weixin_key']['info'], $data['v3_pay_weixin_key']['value'])->info($data['v3_pay_weixin_key']['desc']),
Build::input('v3_pay_public_key', $data['v3_pay_public_key']['info'], $data['v3_pay_public_key']['value'])->info($data['v3_pay_public_key']['desc']),
Build::uploadImage('v3_pay_public_pem', $data['v3_pay_public_pem']['info'], $data['v3_pay_public_pem']['value'])
->url('/file/upload/1?type=1')->format(config('upload.fileExt'))->headers(['Authori-zation' => app()->request->header('Authori-zation')])
->type('file')->icon('md-add')->info($data['v3_pay_public_pem']['desc']),
])->control(0, [
Build::input('pay_weixin_key', $data['pay_weixin_key']['info'], $data['pay_weixin_key']['value'])->info($data['pay_weixin_key']['desc']),
])->options($this->getOptions($data['pay_wechat_type']['parameter']))->info($data['pay_wechat_type']['desc']),
Build::uploadImage('pay_weixin_client_cert', $data['pay_weixin_client_cert']['info'], $data['pay_weixin_client_cert']['value'])
->url('/file/upload/1?type=1')->format(config('upload.fileExt'))->headers(['Authori-zation' => app()->request->header('Authori-zation')])
->type('file')->icon('md-add')->info($data['pay_weixin_client_cert']['desc']),
Build::uploadImage('pay_weixin_client_key', $data['pay_weixin_client_key']['info'], $data['pay_weixin_client_key']['value'])
->url('/file/upload/1?type=1')->format(config('upload.fileExt'))->headers(['Authori-zation' => app()->request->header('Authori-zation')])
->type('file')->icon('md-add')->info($data['pay_weixin_client_key']['desc']),
Build::switch('pay_routine_open', $data['pay_routine_open']['info'], (int)$data['pay_routine_open']['value'])->control(1, [
Build::input('pay_routine_mchid', $data['pay_routine_mchid']['info'], $data['pay_routine_mchid']['value'])->info($data['pay_routine_mchid']['desc'])
])->trueValue('开启', 1)->falseValue('关闭', 0)->info($data['pay_routine_open']['desc'])
])->trueValue('开启', 1)->falseValue('关闭', 0)->info($data['pay_weixin_open']['desc']),
])->option('余额支付', [
Build::switch('balance_func_status', $data['balance_func_status']['info'], (int)$data['balance_func_status']['value'])->falseValue('关闭', 0)->trueValue('开启', 1)->control(1, [
Build::switch('yue_pay_status', $data['yue_pay_status']['info'], (int)$data['yue_pay_status']['value'])->trueValue('开启', 1)->falseValue('关闭', 2)->info($data['yue_pay_status']['desc'])
])->info($data['balance_func_status']['desc']),
])->option('线下支付', [
Build::switch('offline_pay_status', $data['offline_pay_status']['info'], (int)$data['offline_pay_status']['value'])->trueValue('开启', 1)->falseValue('关闭', 2)->info($data['offline_pay_status']['desc'])
])->option('支付宝支付', [
Build::alert('登录支付宝商家(地址:https://b.alipay.com,需要配置ip白名单以及回调地址回调地址:' . $site_url . '),帮助文档地址:https://doc.crmeb.com/web/pro/crmebprov2/1204', Alert::WARNING)->showIcon(true),
Build::switch('ali_pay_status', $data['ali_pay_status']['info'], (int)$data['ali_pay_status']['value'])->control(1, [
Build::input('ali_pay_appid', $data['ali_pay_appid']['info'], $data['ali_pay_appid']['value'])->info($data['ali_pay_appid']['desc']),
Build::input('alipay_public_key', $data['alipay_public_key']['info'], $data['alipay_public_key']['value'])->rows(5)->type('textarea')->info($data['alipay_public_key']['desc']),
Build::input('alipay_merchant_private_key', $data['alipay_merchant_private_key']['info'], $data['alipay_merchant_private_key']['value'])->rows(5)->type('textarea')->info($data['alipay_merchant_private_key']['desc']),
])->trueValue('开启', 1)->falseValue('关闭', 0)->info($data['ali_pay_status']['desc']),
]),
]);
return $build->toArray();
}
3,文件地址:crmeb/services/wechat/DefaultConfig.php
找到WECHAT_CONFIG给v3_pay新增参数如下图:
'public_key'=>[
//默认使用value值,没有值使用eb_system_config配置中的key的值
'key' => 'v3_pay_public_key',
//配置值
'value' => '',
],
'public_pem'=>[
//默认使用value值,没有值使用eb_system_config配置中的key的值
'key' => 'v3_pay_public_pem',
//配置值
'value' => '',
],
4,文件地址:crmeb/services/wechat/config/V3PaymentConfig.php
添加属性:如下图
public string $publicKey;
public string $publicPem;
找到初始化方法init()
新增一下代码,如下图:
$this->publicKey = $this->httpConfig->getConfig('v3_pay.public_key', '');
$this->publicPem = str_replace('//', '/', public_path() . $this->httpConfig->getConfig('v3_pay.public_pem', ''));
5,文件地址:crmeb/services/wechat/v3pay/BaseClient.php
方法:getPublicKey
修改代码如下图:
if ($this->config->publicKey != '') {
$key_path = $this->config->publicPem;
} else {
$key_path = $this->config->certPath;
}
方法名:request
修改代码如下图
if ($serial) {
if ($this->config->publicKey != '') {
$options['headers']['Wechatpay-Serial'] = $this->config->publicKey;
} else {
$options['headers']['Wechatpay-Serial'] = $this->getCertficatescAttr('serial_no');
}
}