jemoker/wxpay

微信支付SDK在Laravel5封装包。

dev-master 2018-09-21 08:47 UTC

This package is not auto-updated.

Last update: 2024-11-04 13:24:48 UTC


README

自用 WeiXin Payment

###Install

  1. 修改composer.json文件,加入"jemoker/wxpay": "dev-master"
  "require": {
    "jemoker/wxpay": "dev-master"
  }
  1. 修改app/config/app.php
'providers' => array(
  		'Jemoker\Wxpay\WxpayServiceProvider'
)


'aliases' => array(
		'Wxpay' => 'Jemoker\Wxpay\Facades\WxpayFacade'
)
  1. 运行composer update 命令
  2. 运行php artisan config:publish jemoker/wxpay
  3. 如有必要修改支付页面,运行php artisan view:publish jemoker/wxpay

###Usage

支付调用

  $wxpay = app('wxpay');
  $params = array(
  	'body' => 'xxx',
  	'total_fee' => 'xxx',
  	'out_trade_no' => 'xxx',
  	'notify_url' => 'xxx',
  	'call_back_url' => 'xxx'
  );
  $wxpay->setParams($params);

支付回调

  $wxpay = app('wxpay');
  $notify = $wxpay->verifyNotify(); 
  
  if($notify){
    //业务逻辑
    switch ($wxpay->data['result_code']) {
    	...
    }
    return 'success';
  }else{
    //业务逻辑
    return 'fail';
  }