Home >php教程 >php手册 >(用微信扫的静态链接二维码)微信native支付模式官方提供的demo文件中的几个bug修正,nativedemo

(用微信扫的静态链接二维码)微信native支付模式官方提供的demo文件中的几个bug修正,nativedemo

WBOY
WBOYOriginal
2016-06-13 09:21:251444browse

(用微信扫的静态链接二维码)微信native支付模式官方提供的demo文件中的几个bug修正,nativedemo

native支付模式一demo(用微信扫的静态链接二维码)BUG修复,一共4个BUG

1.native_call_qrcode.php这个文件中的代码无法生存native支付的短地址
2.WxPayPubHelper.php中某个代码获取不到WxPayConf_pub类定义的常量CURL_TIMEOUT
3.WxPayPubHelper.php curl中cURL会话并且异常释放资源
4.微信支付长地址转换地址函数有误

1.纠正短微信短地址未生成支付二维码问题,页面地址native_call_qrcode.php
第39行:因为官方的$codeUrl获得为空。
第59行:

<span>var</span> url = "<?php echo <span>$product_url</span>;?>";

获得是长地址
修改为短地址:

<span>var</span> url = "<?php echo <span>$codeUrl</span>;?>";

长地址的字符信息量太大常常会导致扫码失败。

2.WxPayPubHelper.php中某个代码获取不到WxPayConf_pub类定义的常量CURL_TIMEOUT


WxPayPubHelper/WxPayPubHelper.php
第155行

curl_setopt(<span>$ch</span>, CURLOP_TIMEOUT, <span>$second</span>);

这里获取不到CURLOP_TIMEOUT
应该改成

curl_setopt(<span>$ch</span>, WxPayConf_pub::CURL_TIMEOUT, <span>$second</span>);

3.WxPayPubHelper.php curl中cURL会话并且异常释放资源
第176行 return $data;是画蛇添足的的,这里也会报错,因为第171行:

curl_close(<span>$ch</span>);

已经关闭流

4.微信支付长地址转换地址函数有误
第600行 getShortUrl()获取不到短地址,

<span>function</span><span> getShortUrl()
{
</span><span>$this</span>-><span>postXml();
</span><span>$prepay_id</span> = <span>$this</span>->result["short_url"<span>];
</span><span>return</span> <span>$prepay_id</span><span>;
}</span>

 

修改如下

<span>function</span><span> getShortUrl()
{

</span><span>$this</span>-><span>postXml();
</span><span>$postObj</span> = <span>simplexml_load_string</span>(<span>$this</span>->response, 'SimpleXMLElement',<span> LIBXML_NOCDATA);
</span><span>$prepay_id</span> = <span>$postObj</span>-><span>short_url;
</span><span>return</span> <span>$prepay_id</span><span>;
}</span>

微信开发交流 QQ:187395037  电话:15889726201

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn