search
Homephp教程php手册开发微信支付的一点心得

由于使用了别人封装的微信公众平台SDK http://www.cnblogs.com/x3d/p/3740454.html  ,所以省去了完整理解开发手册的时间。

微信支付,即便交了保证金,你还是处理测试阶段,不能正式发布。必须到你通过程序测试提交订单、发货通知等数据到微信的系统中,才能申请发布。

然后,因为在微信中是通过JS方式调用API,必须在微信后台设置支付授权目录,而且要到二级三级目录下去,这对于使用MVC框架来说,是个小问题。

使用MVC,在开发环境,url往往是native url格式,不能保证一定是带有路径/的形式

 

所以,比较可靠的方式,是创建实体的子文件夹,这样的化,在系统整体url方面,需要进行一些改造。

 

另外,最后一步,js调用时,对于 https://github.com/dodgepudding/wechat-php-sdk  这里提供的js库,在调用时,必须确保在页面加载完后触发,即WeixinJSBridgeReady的状态,因为这时才能与微信浏览器提供jsbridge进行通讯。

5.24修复

具体可看微擎中的相关代码。

<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>

 

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function