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