Download the PHP package yuyue8/tp-wechat without Composer
On this page you can find all versions of the php package yuyue8/tp-wechat. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yuyue8/tp-wechat
More information about yuyue8/tp-wechat
Files in yuyue8/tp-wechat
Package tp-wechat
Short Description thinkphp使用w7corp/easywechat,实现wechat常用功能和接口
License Apache-2.0
Informations about the package tp-wechat
TpWechat
安装
composer require yuyue8/tp-wechat
微信公众号
微信公众号配置
在tp_wechat配置文件内修改wechat配置
微信公众号服务接口
在控制器中添加以下代码,并在公众号后台设置该接口
微信公众号内置功能
若使用内置的关注、取消关注、模版消息功能,需要创建相关数据表,创建语句如下:
然后运行Yuyue8\TpWechat\jobs\WechatNoticeSendJobs消息队列,对消息进行处理
模版消息发送
在template配置文件设置模版消息相关配置,然后调用Yuyue8\TpWechat\services\WechatNoticeRecordServices类的sendTemplate方法,
将会保存消息记录到数据表,并进入Yuyue8\TpWechat\jobs\WechatNoticeSendJobs消息队列
自定义微信公众号相关功能
如需自定义微信公众号相关功能,只需以下步骤:
创建微信服务类,继承Yuyue8\TpWechat\service\WechatService类或者Yuyue8\TpWechat\interfaces\WechatInterface接口,并实现相关方法
在provider.php文件中绑定微信服务类到接口
例如:
创建的微信服务类为app\service\Wechat,在provider.php文件中添加
后续所有操作将由app\service\Wechat类完成
微信支付
微信支付配置
在tp_wechat配置文件内修改wechat_pay配置
微信支付服务接口
在控制器中添加以下代码,并在商户号后台设置该接口,以接受订单支付通知和退款通知
由于订单数据表没有规则,所以请自行实现订单支付通知和退款通知后续操作,具体步骤如下:
🚨🚨🚨 注意:推送信息不一定靠谱哈,请务必验证 建议是拿订单号调用微信支付查询接口,以查询到的订单状态为准
自定义微信支付相关功能
Yuyue8\TpWechat\service\WechatPayService类内置了下单退单等功能,直接调用即可
如需自定义支付相关功能,只需以下步骤:
创建微信支付服务类,继承Yuyue8\TpWechat\service\WechatPayService类或者Yuyue8\TpWechat\interfaces\WechatPayInterface接口,并实现相关方法
在provider.php文件中绑定微信支付服务类到接口
例如:
创建的微信支付服务类为app\service\PayWechat,在provider.php文件中添加
更新微信支付平台证书
Yuyue8\TpWechat\service\WechatPayService类中的updatePlatformCerts方法可以更新微信支付平台证书,请每个商户号每天执行一次
警告
考虑到效率和多商户的情况,Yuyue8\TpWechat\service\WechatService类和Yuyue8\TpWechat\service\WechatPayService类中使用了单例且属性值为数组,所以在修改了tp_wechat配置文件或更新平台证书后,一定要重启或重置以下类,否则修改的配置和平台证书将不会生效
Yuyue8\TpWechat\service\WechatService类、Yuyue8\TpWechat\service\WechatPayService类和Yuyue8\TpWechat\interfaces\WechatPayInterface接口
例如:
All versions of tp-wechat with dependencies
topthink/framework Version ^6.0 | ^8.0
w7corp/easywechat Version ^6.7
yuyue8/tp_queue Version ^1.0
yuyue8/tp_driver Version ^1.0