The certs(***)
contains the merchant’s certificate serial number(***) which is not allowed here.
这个报错,就是用错了 证书
是你不恰当地把商户证书序列号,填在了平台证书序列号位置,SDK替你做了判断,你这种配置方法错了。
举个例子,都是钥匙,你家的钥匙和我家的钥匙,都是钥匙,但是你不能拿你家的来开我家的门,这就是非对称加解密技术的概要。
read.me中有段话:
你需要先手工 下载平台证书 才能使用 SDK 发起请求。
怎么下载,这里我用了 composer 安装,使用下面命令
composer exec CertificateDownloader.php -- -k ${apiV3key} -m ${mchId} -f ${mchPrivateKeyFilePath} -s ${mchSerialNo} -o ${outputFilePath}
参数说明:
-m, --mchid=<merchantId> 商户号
-s, --serialno=<serialNo> 商户证书的序列号
-f, --privatekey=<privateKeyFilePath>
商户的私钥文件
-k, --key=<apiV3key> ApiV3Key
-o, --output=[outputFilePath]
下载成功后保存证书的路径,可选参数,默认为临时文件目录夹
-u, --baseuri=[baseUri] 接入点,默认为 https://api.mch.weixin.qq.com/
-V, --version Print version information and exit.
-h, --help Show this help message and exit.
直接喂你嘴里,我的命令为:
root@98f93f1bd4aa:/var/www/html/extension# pwd
/var/www/html/extension
root@98f93f1bd4aa:/var/www/html/extension# composer exec CertificateDownloader.php -- -k 10SopwGN**K2h2A8GQ -m 167**903 -f /var/www/html/extension/extend/wechatpay/cert2/apiclient_key.pem -s 6060E85**18086180 -o ./
此时会生成一个文件在当前目录下,拷贝到你想要的目录下
支付代码修改为:
$platformCertificateFilePath = file_get_contents(EXTEND_PATH.'wechatpay/cert2/wechatpay_11C0A82***75725AD1E.pem');
$platformPublicKeyInstance = Rsa::from($platformCertificateFilePath, Rsa::KEY_TYPE_PUBLIC);
结束
参考链接
https://github.com/wechatpay-apiv3/wechatpay-php/issues/26
https://github.com/wechatpay-apiv3/wechatpay-php#%E5%A6%82%E4%BD%95%E4%B8%8B%E8%BD%BD%E5%B9%B3%E5%8F%B0%E8%AF%81%E4%B9%A6
https://github.com/wechatpay-apiv3/wechatpay-php/blob/main/bin/README.md