服务商特约商户进件提交申请单密文加密错误
错误信息: {"code""PARAM_ERROR","message""请确认待处理的消息是否为加密后的密文"}
看到特约商户更新了文档之后,我采用的是最新的API-v3接口规则 请求头如下(证书序列号是微信支付平台序列号): array("Content-Type: application/json","Accept:application/json","User-Agent:".$_SERVER['HTTP_USER_AGENT'],"Authorization:"$this->authorization,"Wechatpay-Serial:"$this->cert_sn)
验签如下(验签使用的是商户平台私钥): $url_parts = parse_url($url);
$canonical_url = ($url_parts['path'] . (!empty($url_parts['query'])) ? "?${url_parts['query']}" : ""));
$message = strtoupper($http_method).'\n'.canonical_url.'\n'.
$timestamp.'\n'.
$nonce.'\n'.
$body.'\n';
$pri_key_string = file_get_contents($this->apiclient_key);
$pri_key = openssl_get_privatekey($pri_key_string);
if(!openssl_sign(message, raw_sign, pri_key, 'sha256WithRSAEncryption')){
throw new WxPayException('make sign failed:'.PHP_EOL);
}
$sign = base64_encode($raw_sign);
加密敏感信息(使用微信支付平台公钥): $pub_key_string = file_get_contents($this->cert_path);
$pub_key = openssl_get_publickey($pub_key_string);
$encrypted = '';
if(openssl_public_encrypt($str,$encrypted,$pub_key,OPENSSL_PKCS1_OAEP_PADDING)){
return base64_encode($encrypted);
}
麻烦看一下是什么问题,官方给的错误信息没有明确指出是哪个字段加密出错,现在找不到处理的办法了。