Home  >  Article  >  Backend Development  >  Some tips on developing WeChat payment_PHP tutorial

Some tips on developing WeChat payment_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:29:31964browse

Because we use the WeChat public platform SDK http://www.cnblogs.com/x3d/p/3740454.html packaged by others, we save time on fully understanding the development manual.

With WeChat payment, even if you pay a deposit, you are still in the testing phase and cannot be officially released. You must submit orders, shipping notifications and other data to the WeChat system through program testing before you can apply for release.

Then, because the API is called through JS in WeChat, the payment authorization directory must be set up in the WeChat backend, and it must go to the second and third level directories. This is a small problem when using the MVC framework.

When using MVC, in the development environment, the url is often in the native url format, and there is no guarantee that it must be in the form of path/

So, a more reliable way is to create a subfolder of the entity. This requires some modifications in the overall URL of the system.

In addition, in the last step, when calling js, for the js library provided here at https://github.com/dodgepudding/wechat-php-sdk, when calling, you must ensure that it is triggered after the page is loaded, that is, WeixinJSBridgeReady status, because only then can we communicate with the jsbridge provided by WeChat browser.

5.24 fix

For details, please see the relevant code in WeQing.

<script type="text/javascript"><span>
document</span>.addEventListener('WeixinJSBridgeReady', <span>function</span><span> onBridgeReady() {
    WeixinJSBridge</span>.invoke('getBrandWCPayRequest',<span> {
        </span>'appId' : '<?php echo $wOpt['appId'];?>',
        'timeStamp': '<?php echo $wOpt['timeStamp'];?>',
        'nonceStr' : '<?php echo $wOpt['nonceStr'];?>',
        'package' : '<?php echo $wOpt['package'];?>',
        'signType' : '<?php echo $wOpt['signType'];?>',
        'paySign' : '<?php echo $wOpt['paySign'];?>'<span>
    }</span>, <span>function</span><span>(res) {
        </span><span>if</span>(res.err_msg == 'get_brand_wcpay_request:ok'<span>) {
        } </span><span>else</span><span> {
            alert(</span>'启动微信支付失败, 请检查你的支付参数. 详细错误为: ' + res.<span>err_msg);
        }
        history</span>.go(-1<span>);
    });
}</span>, <span>false</span><span>);
</span></script>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/775948.htmlTechArticleDue to the use of the WeChat public platform SDK packaged by others http://www.cnblogs.com/x3d/p/ 3740454.html, so it saves the time of fully understanding the development manual. WeChat payment, even if you pay a guarantee...
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