利用了wechatpay-guzzle-middleware和wechatpay-php扩展;
微信支付平台证书是通过./bin/CertificateDownloader.php -k..........下载的;
加密方法利用了php demo
private function getEncrypt($str){
//$str是待加密字符串
$public_key_path = '平台证书路径';
$public_key = file_get_contents($public_key_path);
$encrypted = '';
if (openssl_public_encrypt($str,$encrypted,$public_key,OPENSSL_PKCS1_OAEP_PADDING)) {
//base64编码
$sign = base64_encode($encrypted);
} else {
throw new Exception('encrypt failed');
}
return $sign;
}
进行POST提交api.mch.weixin.qq.com/v3/ecommerce/applyments/后返回为
{"code":"PARAM_ERROR","message":"证书类型格式错误,请重新选择"}
我哪里出错了?大佬帮忙指导一下
https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay4_3.shtml
如果我用api证书公钥来加密,提示错误
{"code":"PARAM_ERROR","message":"平台私钥解密失败"}
通过文档来看,应该用微信支付平台证书来加密