zoukankan      html  css  js  c++  java
  • 微信支付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>");
    }
    }
  • 相关阅读:
    微信小程序自定义navigationBar
    微信小程序-自动定位并将经纬度解析为具体地址
    a conexant audio couldnot befound
    平衡二叉树(AVL)java实现
    二叉树的各种非递归遍历
    选择排序
    快速排序
    冒泡排序
    数组洗牌
    haffman树c实现
  • 原文地址:https://www.cnblogs.com/luluzc/p/8962020.html
Copyright © 2011-2022 走看看