tp5 微信JSAPI支付

1、开通服务号,开通商户号,设置授权域名。

2、下载sdk:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=11_1;下载支付证书:https://pay.weixin.qq.com/index.php/account/api_cert

3、sdk中php_sdk_v3.0.10文件夹改名为wxpay,复制到application之下

4、将example里的文件拷到wxpay/controller目录下,文件开头加 namespace appwxpaycontroller;

修改require_once 路径

5、WxPay.Config.php文件中填写:

class WxPayConfig extends WxPayConfigInterface
{
    //=======【基本信息设置】=====================================
    /**
     * TODO: 修改这里配置为您自己申请的商户信息
     * 微信公众号信息配置
     * 
     * APPID:绑定支付的APPID(必须配置,开户邮件中可查看)
     * 
     * MCHID:商户号(必须配置,开户邮件中可查看)
     * 
     */
    const APPID = ""//公众号appid;
    const MCHID = ""//商户号;
    const KEY = ""//秘钥;
    const APPSECRET = ""//APPsecret;

6、将jsapi.php中的代码添加class Jsapi extends Controller。

将function printf_info()以外的代码集中到function index()中末尾添加代码:

$assign = array('jsApiParameters' => $jsApiParameters);
        $this->assign($assign);
        $this->display();
        return $this->fetch();
7、将底部html复制到view/jsapi/index.html中。
原文地址:https://www.cnblogs.com/wangyinqiuqian/p/13565798.html