设为首页 加入收藏

TOP

微信web端生成支付二维码(四)
2017-10-10 12:01:58 】 浏览:8081
Tags:微信 web 生成 支付 二维
de_no;//商户订单号 // $total_fee = $postObj->total_fee; //订单总金额,单位为分 // $is_subscribe = $postObj->is_subscribe; //用户是否关注公众账号,Y-关注,N-未关注,仅在公众账号类型支付有效 // $attach = $postObj->attach;//商家数据包,原样返回 // $time_end = $postObj->time_end;//支付完成时间
echo '<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>'; return $postObj; } } /** * curl get * @param string $url * @param array $options * @return mixed */ private function curlGet($url = '', $options = array()) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 30); if (!empty($options)) { curl_setopt_array($ch, $options); } //https请求 不验证证书和host curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $data = curl_exec($ch); curl_close($ch); return $data; } /** * curl post * @param string $url * @param array $options * @return mixed */ private function curlPost($url = '', $postData = '', $options = array()) { if (is_array($postData)) { $postData = http_build_query($postData); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt($ch, CURLOPT_TIMEOUT, 30); //设置cURL允许执行的最长秒数 if (!empty($options)) { curl_setopt_array($ch, $options); } //https请求 不验证证书和host curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $data = curl_exec($ch); curl_close($ch); return $data; } /** * 随机生成一定长度字符串 * @param string $url * @param array $options * @return mixed */ private function createNonceStr($length = 16) { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $str = ''; for ($i = 0; $i < $length; $i++) { $str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1); } return $str; } /** * 数组转成XML * @param string $url * @param array $options * @return mixed */ private function arrayToXml($arr) { $xml = "<xml>"; foreach ($arr as $key => $val) { if (is_numeric($val)) { $xml .= "<" . $key . ">" . $val . "</" . $key . ">"; } else $xml .= "<" . $key . "><![CDATA[" . $val . "]]></" . $key . ">"; } $xml .= "</xml>"; return $xml; } /** * 例如: * appid: wxd930ea5d5a258f4f * mch_id: 10000100 * device_info: 1000 * Body: test * nonce_str: ibuaiVcKdpRxkhJA * 第一步:对参数按照 key=value 的格式,并按照参数名 ASCII 字典序排序如下: * stringA="appid=wxd930ea5d5a258f4f&body=test&device_info=1000&mch_i * d=10000100&nonce_str=ibuaiVcKdpRxkhJA"; * 第二步:拼接支付密钥: * stringSignTemp="stringA&key=192006250b4c09247ec02edce69f6a2d" * sign=MD5(stringSignTemp).toUpperCase()="9A0A8659F005D6984697E2CA0A9CF3B7" */ private function getSign($params, $key) { ksort($params, SORT_STRING); $unSignParaString = $this->formatQueryParaMap($params, false); $signStr = strtoupper(md5($unSignParaString . "&key=" . $key)); return $signStr; } /** * 签名时字符组合 * @param string $url * @param array $options * @return mixed */ pri
首页 上一页 1 2 3 4 5 下一页 尾页 4/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇windows7下的PHP开发环境搭建(iis.. 下一篇Mac版PhpStorm之XAMPP整合apache..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目