From 882fcc60a83396c662bc3c9f7d5bd8a25751c6c0 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 09:33:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=85=BC=E5=AE=B9=EF=BC=8C=E5=B7=B2=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E6=B5=8B=E8=AF=95=20#92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _test/pay-v3-config.php | 42 ++++++++++++++++------------- readme.md | 58 +++++++++++++++++++++++++++-------------- 2 files changed, 63 insertions(+), 37 deletions(-) diff --git a/_test/pay-v3-config.php b/_test/pay-v3-config.php index 66f48c9..8c6f97c 100644 --- a/_test/pay-v3-config.php +++ b/_test/pay-v3-config.php @@ -14,37 +14,38 @@ // | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper // +---------------------------------------------------------------------- +// 微信商户证书公钥 $certPublic = << function ($name, $value, $expired = 360) { // var_dump(func_get_args()); -// return $value; +// return $value; // }, // 'get' => function ($name) { // var_dump(func_get_args()); @@ -61,26 +62,31 @@ CERT; // ]; return [ - // 可选,公众号APPID + // 公众号 APPID(可选) 'appid' => 'wx3760xxxxxxxxxxxx', - // 必填,微信商户编号ID + // 微信商户号(必填) 'mch_id' => '15293xxxxxx', - // 必填,微信商户V3接口密钥 + // 微信商户 V3 接口密钥(必填) 'mch_v3_key' => '98b7fxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - // 可选,微信商户证书序列号,可从公钥中提取,请求签名使用 + + // 商户证书序列号(可选):用于请求签名 'cert_serial' => '49055D67B2XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', - // 必填,微信商户证书公钥,支持证书内容或文件路径,仅用于提取序号 + // 微信商户证书公钥(必填):可填写证书内容或文件路径,仅用于提取序列号 'cert_public' => $certPublic, - // 必填,微信商户证书私钥,支持证书内容或文件路径,用于请求数据签名 + // 微信商户证书私钥(必填):可填写证书内容或文件路径,用于请求数据签名 'cert_private' => $certPrivate, - // 批量设置自定义证书内容,支持平台证书或支付公钥,可填写文件路径及内容 + + // 自定义证书包:支持平台证书或支付公钥(可填写文件路径或证书内容) 'cert_package' => [ 'PUB_KEY_ID_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' => $certPayment ], - // 可选,微信平台证书序号或支付证书序号,直接支持平台证书或支付公钥 + + // 微信平台证书或支付证书序列号(可选) // 'mp_cert_serial' => 'PUB_KEY_ID_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - // 可选,微信平台证书内容或支付证书内容,直接支持平台证书或支付公钥 + + // 微信平台证书或支付证书内容(可选) // 'mp_cert_content' => $certPayment, - // 可选,运行时的文件缓存路径 + + // 运行时文件缓存路径(可选) 'cache_path' => '' ]; \ No newline at end of file diff --git a/readme.md b/readme.md index 14214de..847b991 100644 --- a/readme.md +++ b/readme.md @@ -117,17 +117,18 @@ include "您的目录/WeChatDeveloper/include.php"; 2.1 接口实例所需参数 ```php + // ===================================================== -// 配置缓存处理函数 ( 适配其他环境 ) +// 配置缓存处理函数(适配不同环境) // ----------------------------------------------------- -// 数据缓存 (set|get|del) 操作可以将缓存写到任意位置或Redis -// 文件缓存 (put) 只能写在本地服务器,还需要返回可读的文件路径 -// 未配置自定义缓存处理机制时,默认在 cache_path 写入文件缓存 -// // ===================================================== +// - 数据缓存(set|get|del):可存储到本地或 Redis +// - 文件缓存(put):仅支持本地存储,并返回可读的文件路径 +// - 若未设置自定义缓存处理,默认存储在 cache_path 目录 +// ===================================================== // \WeChat\Contracts\Tools::$cache_callable = [ // 'set' => function ($name, $value, $expired = 360) { // var_dump(func_get_args()); -// return $value; +// return $value; // }, // 'get' => function ($name) { // var_dump(func_get_args()); @@ -143,19 +144,38 @@ include "您的目录/WeChatDeveloper/include.php"; // }, // ]; -$config = [ - 'token' => 'test', - 'appid' => 'wx60a43dd8161666d4', - 'appsecret' => '71308e96a204296c57d7cd4b21b883e8', - 'encodingaeskey' => 'BJIUzE0gqlWy0GxfPp4J1oPTBmOrNDIGPNav1YFH5Z5', - // 配置商户支付参数(可选,在使用支付功能时需要) - 'mch_id' => "1235704602", - 'mch_key' => 'IKI4kpHjU94ji3oqre5zYaQMwLHuZPmj', - // 配置商户支付双向证书目录(可选,在使用退款|打款|红包时需要) - 'ssl_key' => '', - 'ssl_cer' => '', - // 缓存目录配置(可选,需拥有读写权限) - 'cache_path' => '', +return [ + // 公众号 APPID(可选) + 'appid' => 'wx3760xxxxxxxxxxxx', + + // 微信商户号(必填) + 'mch_id' => '15293xxxxxx', + + // 微信商户 V3 接口密钥(必填) + 'mch_v3_key' => '98b7fxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + + // 商户证书序列号(可选):用于请求签名 + 'cert_serial' => '49055D67B2XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + + // 微信商户证书公钥(必填):可填写证书内容或文件路径,仅用于提取序列号 + 'cert_public' => $certPublic, + + // 微信商户证书私钥(必填):可填写证书内容或文件路径,用于请求数据签名 + 'cert_private' => $certPrivate, + + // 自定义证书包:支持平台证书或支付公钥(可填写文件路径或证书内容) + 'cert_package' => [ + 'PUB_KEY_ID_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' => $certPayment + ], + + // 微信平台证书或支付证书序列号(可选) + // 'mp_cert_serial' => 'PUB_KEY_ID_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', + + // 微信平台证书或支付证书内容(可选) + // 'mp_cert_content' => $certPayment, + + // 运行时文件缓存路径(可选) + 'cache_path' => '' ]; ```