Home > Backend Development > PHP Tutorial > (Static link QR code scanned with WeChat) Several bug corrections in the demo file officially provided by WeChat native payment model, nativedemo_PHP tutorial

(Static link QR code scanned with WeChat) Several bug corrections in the demo file officially provided by WeChat native payment model, nativedemo_PHP tutorial

WBOY
Release: 2016-07-13 10:14:25
Original
1301 people have browsed it

(Static link QR code scanned with WeChat) Several bug corrections in the demo file officially provided by WeChat native payment mode, nativedemo

native payment mode 1 Demo (static link QR code scanned with WeChat) bug fix, a total of 4 bugs

1. The code in the native_call_qrcode.php file cannot survive the native payment short address
2. A certain code in WxPayPubHelper.php cannot obtain the constant CURL_TIMEOUT defined by the WxPayConf_pub class
3. WxPayPubHelper.php curl The cURL session is in progress and resources are released abnormally
4. The WeChat payment long address conversion address function is incorrect

1. Correct the problem that the payment QR code is not generated from the WeChat short message address. The page address native_call_qrcode.php
line 39: because the official $codeUrl is empty .
Line 59:

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

Get the long address
Change it to the short address:

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

The amount of character information in a long address often causes scan failure.

2. A certain code in WxPayPubHelper.php cannot obtain the constant CURL_TIMEOUT defined by the WxPayConf_pub class


WxPayPubHelper/WxPayPubHelper.php
Line 155

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

CURLOP_TIMEOUT cannot be obtained here
should be changed to

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

3. The cURL session in WxPayPubHelper.php curl and the resource is released abnormally
Line 176 return $data; is superfluous, and an error will be reported here because line 171:

curl_close(<span>$ch</span>);
Copy after login

Stream has been closed

4. The WeChat payment long address conversion address function is incorrect
Line 600 getShortUrl() cannot obtain the short address,

<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>
Copy after login

Modify as follows

<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>
Copy after login

WeChat development communication QQ:187395037 Tel: 15889726201

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/909746.htmlTechArticle(Static link QR code scanned with WeChat) Several of the demo files officially provided by WeChat native payment model Bug fix, nativedemo native payment mode demo (static link QR code scanned with WeChat...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template