微信支付HTTPS服务器证书验证(php)

微信支付更换CA证书,提示有可能影响支付。
/**请求方式 post

* 请求格式 xml
* 测试微信支付证书
* @param mch_id 微信商户号
* @param nonce_str 随机数
* @param sign 签名
*/
public function index()
{
$data=array(
"mch_id"=>'商户号',
"nonce_str"=> md5(time()),
);
$newdata = http_build_query ($data)."&key=支付密钥";
$sign = strtoupper(md5($newdata));
$data["sign"] = $sign;

$postdata = arrayToXml($data);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://apitest.mch.weixin.qq.com/sandboxnew/pay/getsignkey");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);

//curl 60 错误时加上一下的两行
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_HEADER,0); $returncode =curl_exec($ch); if($error=curl_errno($ch)){ echo $error; } curl_close($ch); $toXml = simplexml_load_string($returncode, 'SimpleXMLElement', LIBXML_NOCDATA); $arrXml = (array)$toXml; if ($arrXml['return_code'] == 'SUCCESS') { die('你的服务器经过微信支付HTTPS服务器证书验证'); } if ($arrXml['return_code'] == 'FAIL') { die("你的服务器没法经过验证:" . $arrXml['return_msg'] . ";" . "<a hre='https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=23_4'>点我查看如何安装微信要求的根CA证书</a>"); }}
相关文章
相关标签/搜索