wujingke / pingpp-laravel5-plus by wujingke
forked from lyt8384/pingpp-laravel5-plus

Simple Pingpp wrapper for Laravel 5
4
0
1
Package Data
Maintainer Username: wujingke
Maintainer Contact: hi.laow@gmail.com (JingKeWu)
Package Create Date: 2016-02-23
Package Last Update: 2016-02-23
Language: PHP
License: MIT
Last Refreshed: 2024-11-19 03:22:11
Package Statistics
Total Downloads: 4
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

pingpp-laravel5-plus

pingxx基于laravel5的封装

配置方法

  1. composer.json里添加如下内容,并运行composer update:
{
    "require": {
        "wujingke/pingpp-laravel5-plus": "dev-master"
    }
}
  1. app/config/app.php文件里的providers变量下添加JingKe\Pingpp\PingppServiceProvider::class,
  2. app/config/app.php文件里的aliases变量下添加'Pingpp' => JingKe\Pingpp\Facades\Pingpp::class,
  3. 运行php artisan vendor:publish生成配置文件
  4. 修改配置文件里面的2组key
  5. 若需回调验证,请填写pub_key

使用方法

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();返回具体错误内容。

接收 Webhooks 通知

直接调用Pingpp::notice(),若验证成功,会返回通知的array结构数据,若失败直接弹出错误回Pingpp。如果需要记录错误,请自行监听系统错误,详见Errors & Logging

其他使用方法见官方文档PingPlusPlus