在对接支付接口-单笔转账到支付宝账户时,一直返回40003错误“验签出错, 未配置对应签名算法的公钥或者证书”
查看sdk AopClient.php 文件,加密类型 signType 默认是 RSA,完全不知道那里出错了。
在仔细查看接口文档时,在示例中发现 $aop->signType = 'RSA2';$aop = new AopClient ();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = 'your app_id';
$aop->rsaPrivateKey = '请填写开发者私钥去头去尾去回车,一行字符串';
$aop->alipayrsaPublicKey='请填写支付宝公钥,一行字符串';
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='GBK';
$aop->format='json';
$request = new AlipayFundTransToaccountTransferRequest ();
$request->setBizContent("{" .
"\"out_biz_no\":\"3142321423432\"," .
"\"payee_type\":\"ALIPAY_LOGONID\"," .
"\"payee_account\":\"abc@sina.com\"," .
"\"amount\":\"12.23\"," .
"\"payer_show_name\":\"上海交通卡退款\"," .
"\"payee_real_name\":\"张三\"," .
"\"remark\":\"转账备注\"" .
"}");
$result = $aop->execute ( $request);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;
if(!empty($resultCode)&&$resultCode == 10000){
echo "成功";
} else {
echo "失败";
}
我就抱着试一试的心态设置为 RSA2,结果成功了。
然后我又查看了文档中心的签名专区开放平台签名算法名称标准签名算法名称备注RSA2SHA256WithRSA强制要求RSA密钥的长度至少为2048
RSASHA1WithRSA对RSA密钥的长度不限制,推荐使用2048位以上
原来SHA256就是RSA2....尴尬脸