Package Data | |
---|---|
Maintainer Username: | lyt8384 |
Maintainer Contact: | lyt8384@gmail.com (lyt8384) |
Package Create Date: | 2015-12-22 |
Package Last Update: | 2019-07-25 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 03:04:11 |
Package Statistics | |
---|---|
Total Downloads: | 5,059 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 7 |
Total Watchers: | 0 |
Total Forks: | 7 |
Total Open Issues: | 2 |
# pingpp-laravel5-plus pingxx基于laravel5的封装
composer.json
里添加如下内容,并运行composer update
:{
"require": {
"lyt8384/pingpp-laravel5-plus": "dev-master"
}
}
app/config/app.php
文件里的providers变量下添加lyt8384\Pingpp\PingppServiceProvider::class,
app/config/app.php
文件里的aliases变量下添加'Pingpp' => lyt8384\Pingpp\Facades\Pingpp::class,
php artisan vendor:publish --provider="lyt8384\Pingpp\PingppServiceProvider"
生成配置文件public_key_path
,注意该处是路径!,这里参考官方已改为路径,同时当前会兼容旧版本配置文件private_key_path
,注意该处是路径!
线上生产环境建议配置.evn
来配置生产环境use Pingpp;
class SomeClass extends Controller {
public function someFunction()
{
Pingpp::Charge()->create([
'order_no' => '123456789',
'amount' => '100',
'app' => array('id' => 'app_xxxxxxxxxxxxxx'),
'channel' => 'upacp',
'currency' => 'cny',
'client_ip' => '127.0.0.1',
'subject' => 'Your Subject',
'body' => 'Your Body'
]);
}
}
use Pingpp;
class SomeClass extends Controller {
public function someFunction()
{
Pingpp::RedEnvelope()->create([
'order_no' => '123456789',
'app' => array('id' => 'APP_ID'),
'channel' => 'wx_pub',
'amount' => 100,
'currency' => 'cny',
'subject' => 'Your Subject',
'body' => 'Your Body',
'extra' => array(
'nick_name' => 'Nick Name',
'send_name' => 'Send Name'
),
'recipient' => 'Openid',
'description' => 'Your Description'
]);
}
}
当Pingpp调用发生错误的时候会return false
,此时调用Pingpp::getError();
返回具体错误内容。
直接调用Pingpp::notice()
,若验证成功,会返回通知的array
结构数据,若失败直接弹出错误回Pingpp。如果需要记录错误,请自行监听系统错误,详见Errors & Logging
其他使用方法见官方文档PingPlusPlus
感谢几位forked的同学的改进,当时写的很简单,无入侵式的写法,其实在接收webhooks方面,可以用Laravel自己的Events去监听处理,显得更Laravel风格。