本文实例讲述了PHP实现微信退款的方法。分享给大家供大家参考,具体如下:

$obj = new WXRefund('参数');
$obj->refundApi();

直接能用 公众号的参数 自己加上吧 只能帮你们到这了!

<"<xml>";
    foreach ($arr as $key => $val) {
      if (is_numeric($val)) {
        $xml .= "<" . $key . ">" . $val . "</" . $key . ">";
      } else {
        $xml .= "<" . $key . "><![CDATA[" . $val . "]]></" . $key . ">";
      }
    }
    $xml .= "</xml>";
    return $xml;
  }
  /**
   * 签名加密
   * @param $params
   * @param $key
   */
  protected function getSign($params, $key)
  {
    ksort($params, SORT_STRING);
    $unSignParaString = $this->formatQueryParaMap($params, false);
    return $signStr = strtoupper(md5($unSignParaString . "&key=" . $key));
  }
  /**
   * 排序
   * @param $paraMap
   * @param bool $urlEncode
   * @return bool|string
   */
  protected function formatQueryParaMap($paraMap, $urlEncode = false)
  {
    $buff = "";
    ksort($paraMap);
    foreach ($paraMap as $k => $v) {
      if (null != $v && "null" != $v) {
        if ($urlEncode) {
          $v = urlencode($v);
        }
        $buff .= $k . "=" . $v . "&";
      }
    }
    $reqPar = '';
    if (strlen($buff) > 0) {
      $reqPar = substr($buff, 0, strlen($buff) - 1);
    }
    return $reqPar;
  }
  /**
   * 需要使用证书的请求
   * @param $xml
   * @param $url
   * @param int $second
   * @return bool|mixed
   */
  protected function postXmlSSLCurl($xml, $url, $second = 30)
  {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_TIMEOUT, $second);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_SSLCERTTYPE, 'PEM');
    curl_setopt($ch, CURLOPT_SSLCERT, $this->SSLCERT_PATH);
    curl_setopt($ch, CURLOPT_SSLKEYTYPE, 'PEM');
    curl_setopt($ch, CURLOPT_SSLKEY, $this->SSLKEY_PATH);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
    $data = curl_exec($ch);
    if ($data) {
      curl_close($ch);
      return $data;
    } else {
      $error = curl_errno($ch);
      echo "curl出错,错误码:$error" . "<br>";
      curl_close($ch);
      return false;
    }
  }
}

更多关于PHP相关内容感兴趣的读者可查看本站专题:《PHP微信开发技巧汇总》、《php curl用法总结》、《PHP网络编程技巧总结》、《php字符串(string)用法总结》、《PHP中json格式数据操作技巧汇总》及《PHP针对XML文件操作技巧总结》

希望本文所述对大家PHP程序设计有所帮助。

标签:
PHP,微信,退款

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com

评论“PHP实现微信退款的方法示例”

暂无“PHP实现微信退款的方法示例”评论...