crisenchou / laravel-weixinpay by crisenchou

weixin pay for laravel
20
0
2
Package Data
Maintainer Username: crisenchou
Maintainer Contact: crisen@crisen.org (crisenchou)
Package Create Date: 2016-12-01
Package Last Update: 2017-11-06
Language: PHP
License: MIT
Last Refreshed: 2024-05-03 15:21:13
Package Statistics
Total Downloads: 20
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 1
Total Open Issues: 0

laravel -Weixinpay 微信支付

微信支付

安装

使用composer require命令进行安装

composer require "crisen/laravel-weixinpay":"1.0.*"

或者在composer.json中添加

"require": {
		....
        "crisen/laravel-weixinpay": "1.0.*"
 },

配置

注册服务提供者(Service Provider)

'providers' => [  
    ...
    Crisen\LaravelWeixinpay\WxpayServiceProvider::class,
}

添加门面(Facade)

'aliases' => [
    ...
	'Wxpay' => Crisen\LaravelWeixinpay\Facades\Wxpay::class
]

配置文件部署

php artisan vendor:publish

使用方法

统一下单--扫码支付

 $pay = Wxpay::factory('UnifiedOrder');
 $payment = $pay->options([
     'body' => $order->body,
     'out_trade_no' => $order->orderid,
     'total_fee' => 1
 ])->send();
 if ($payment->isSuccessful()) {
     dump($payment->getCodeUrl());
 }

订单查询

   $payment = Wxpay::factory('OrderQuery')->options([
       'out_trade_no' => 'xxxxxxx'//订单号
   ])->send();
   if ($payment->isSuccessful() && $payment->isPaid()) {
       //do something
   }

异步通知

	$payment = Wxpay::factory('notify')->options($request);
	if ($payment->isSuccessful()) {
        //$outTradeNo = $payment->getOutTradeNo(); //do something with $outTradeNo
        $reply = $payment->reply();
        return response($reply);
    }

License

MIT