1.平台证书及平台证书序列号设置错误报错:
- 错误1:
Verify the response’s data with: timestamp=1735184656, nonce=a5806b8cabc923299f8db1a174f3a4d0, signature=FZ5FgD/jtt4J99GKssKWKA/0buBSOAbWcu6H52l2UqqaJKvrsNxvodB569ZFz5G3fbassOQcSh5BFq6hvEMjQ2U3gKyF1muqsX8oufN4pLQpO+SO5CM7q8y/jIiYG18Kn3Iss7jbG/qGTsssscN98tfpUAb3TCWSQB1mVXUgSDWsROthYfduUgsNMC/xe1z1f2Os9L8fYWjqv8Fr5W5sL7+jFzSTibu7XcietZ+G1MusHC606ncF8MU9cNEf5QRHqgkril3e5IEesssEud6bp35sss0I87wgU5eMDZJp2hw==, cert=[2sssssss1FCC3BBA284F5C7889BCD7B47 => …] failed
- 错误2:
certs(175BxxxxE4507EA22FFD9D8B7CCD0218F1E3xxxx)
contains the merchant’s certificate serial number(175BxxxxE4507EA22FFD9D8B7CCD0218F1E3xxxx) which is not allowed here.
- 错误3:
Cannot found the serial(2sssssss1FCC3BBA284F5C7889BCD7B47
)'s configuration, which’s from the response(header:Wechatpay-Serial), your’s 5B1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A
2.重点介绍平台证书 及序列号获取方法
2.1选择商户后台 “验证微信支付身份” 管理证书。
拿到 平台证书的序列号,
2.2 点击 “右上角” 下载证书
获取证书相关链接:https://pay.weixin.qq.com/doc/v3/merchant/4012068814
打开链接后按照提示下载jar包,
jdk下载地址:https://repo.huaweicloud.com/java/jdk/ windows配置环境变量JAVA_HOME:C:\Program Files\Java\jdk-13
path增加:%JAVA_HOME%\bin
java -jar CertificateDownloader.jar -k a3F7t8L2x9K5xxxxx -m 1xxxxxx -f D:\program\WXCertUtil\WXCertUtil\cert\1700367105_20241225_cert\apiclient_key.pem -s 11111122E5678EA22xxxx18F1cdEab3 -o d:
在d盘生成wechatpay开头的pem文件,就是我们要的平台证书。上传到服务器/data/wechat_cert/wechatpay_platform_create_at_202412.pem下
下属代码中的
WECHAT_PAY_PLATFORM_CERTIFICATE=/data/wechat_cert/wechatpay_platform_create_at_202412.pem
WECHAT_PAY_PLATFORM_CERTIFICATE_SERIAL=11D1111B23D5BFD1FddbBBA111F5C7889BC11111
3.支付完整代码
<?php
namespace app\common\util;
use WeChatPay\Builder;
use WeChatPay\Crypto\Rsa;
use WeChatPay\Formatter;
//参考 微信支付文档:https://pay.weixin.qq.com/docs/merchant/apis/in-app-payment/direct-jsons/app-prepay.html
class WeChatPayUtil
{
/**
* 微信开发平台审核通过的应用ID
* @var string
*/
protected $appid = 'xxx';
/**
* 商户ID
* @var string
*/
protected $merchantId = 'xxx';
/**
* 商户v3版本私钥
* @var string
*/
protected $merchantV3PrivateKey = 'xx';
/**
* 「商户API私钥」文件的绝对路径
* @var string
*/
protected $merchantPrivatePath = '\v3_apiclient_key.pem';
/**
* 「商户API证书」的「证书序列号」
* @var string
*/
protected $merchantCertificateSerial = 'xxx';
/**
* 「微信支付平台证书」文件的绝对路径
* @var string
*/
protected $platformCertificate = '\platform_key.pem';
/**
* 「微信支付平台证书」的「证书序列号」
* @var string
*/
protected $platformCertificateSerial = 'xx';
/**
* APIv3 客户端实例