'请到 [后台-应用-app设置] 填写appid 和 appsecret']); } if (empty($wxConfig['cert_pem']) || empty($wxConfig['key_pem'])) { throw new BaseException(['msg' => '请先到后台app设置填写微信支付证书文件']); } // cert目录 $filePath = root_path() . 'runtime/cert/appopen/' . $wxConfig['app_id'] . '/'; $config = [ 'app_id' => $wxConfig['openapp_id'], 'mch_id' => $wxConfig['mchid'], 'key' => $wxConfig['apikey'], // API 密钥 // 如需使用敏感接口(如退款、发送红包等)需要配置 API 证书路径(登录商户平台下载 API 证书) 'cert_path' => $filePath . 'cert.pem', 'key_path' => $filePath . 'key.pem', 'sandbox' => false, // 设置为 false 或注释则关闭沙箱模式 ]; return Factory::payment($config); } }