denghongcai / wxpay by denghongcai
forked from hardywen/wxpay

微信支付 微信js支付 Weixin weixinPay
45
1
2
Package Data
Maintainer Username: denghongcai
Maintainer Contact: admin@dhchouse.com (Hongcai Deng)
Package Create Date: 2015-08-04
Package Last Update: 2015-09-06
Language: PHP
License: MIT
Last Refreshed: 2024-12-17 03:04:41
Package Statistics
Total Downloads: 45
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 1
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

WxPay

WeiXin Payment

###微信支付的配置要点:请留心注意本部分内容,因为这很可能是你遇到的大坑。 1.网页授权(设置错误会出现redirect_url参数错误的错误) 这个网页授权需要登录微信公众平台,点击左侧菜单“开发者中心”,在右侧“权限列表”中找到“网页账号”,点击最右侧的修改,把测试的网址写进去,不要加http。

2.支付授权目录(设置不对会无法发起js支付,因为没有权限,错误为:“getBrandWCPayRequest:fail_no permission to execute” ) 设置好授权目录即可。

###Install

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


'aliases' => array(
	'Wxpay' => HongcaiDeng\Wxpay\Facades\Wxpay::class,
)
  1. 运行composer update 命令
  2. 如有必要修改支付页面,运行php artisan vendor publish

###Usage

支付调用示例

  $config = array(
    'body'=>'',
    'total_fee' =>'',
    'out_trade_no' => $order->id,
    'js_api_call_url' => action('OrderController@pay', ['id' => $order->id]),
    ...
  );
  list($prepay_id, $view) = Wxpay::instance('jsApi')->setConfig($config)->pay();

支付回调

  $wxpay = Wxpay::instance('jsApi');
  list($notify, $data) = $wxpay->verifyNotify(); //验证回调

  if($notify){
    //业务逻辑

    $wxpay->setReturnParameter("return_code","SUCCESS");//设置返回码
    $wxpay->returnXml();
  }else{

    //业务逻辑


    $wxpay->setReturnParameter("return_code","FAIL");//返回状态码
    $wxpay->setReturnParameter("return_msg","签名失败");//返回信息
    $wxpay->returnXml();
  }