Skip to content

Commit

Permalink
i
Browse files Browse the repository at this point in the history
  • Loading branch information
yansongda committed Aug 20, 2017
1 parent e19742c commit 21f26e2
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor/
composer.lock
Empty file added README.md
Empty file.
25 changes: 25 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "yansongda/laravel-pay",
"description": "专注 Alipay 和 WeChat 的 laravel 支付扩展包",
"keywords": ["alipay", "wechat", "pay", "laravel", "package"],
"support": {
"issues": "https://github.com/yansongda/laravel-pay/issues",
"source": "https://github.com/yansongda/laravel-pay"
},
"authors": [
{
"name": "yansongda",
"email": "me@yansongda.cn"
}
],
"require": {
"illuminate/support": "^5.1",
"yansongda/pay": "^1.0"
},
"autoload": {
"psr-4": {
"Yansongda\\LaravelPay\\": "src"
}
},
"license": "MIT"
}
46 changes: 46 additions & 0 deletions config/pay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

return [
'alipay' => [
// 支付宝分配的 APPID
'app_id' => '',

// 支付宝异步通知地址
'notify_url' => '',

// 支付成功后同步通知地址
'return_url' => '',

// 阿里公共密钥,验证签名时使用
'ali_public_key' => '',

// 自己的私钥,签名时使用
'private_key' => '',
],

'wechat' => [
// 公众号APPID
'app_id' => '',

// 小程序APPID
'miniapp_id' => '',

// APP 引用的 appid
'appid' => '',

// 微信支付分配的微信商户号
'mch_id' => '',

// 微信支付异步通知地址
'notify_url' => '',

// 微信支付签名秘钥
'key' => '',

// 客户端证书路径,退款时需要用到。请填写绝对路径,linux 请确保权限问题。pem 格式。
'cert_client' => '',

// 客户端秘钥路径,退款时需要用到。请填写绝对路径,linux 请确保权限问题。pem 格式。
'cert_key' => '',
],
];
19 changes: 19 additions & 0 deletions src/Facades/Pay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Yansongda\LaravelPay\Facades;

use Illuminate\Support\Facades\Facade;


class Pay extends Facade
{
/**
* Return the facade accessor.
*
* @return string
*/
public static function getFacadeAccessor()
{
return 'pay';
}
}
62 changes: 62 additions & 0 deletions src/PayServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace Yansongda\LaravelPay;

use Yansongda\Pay\Pay;
use Illuminate\Support\ServiceProvider;

class PayServiceProvider extends ServiceProvider
{
/**
* 显示是否延迟提供程序的加载.
*
* @var bool
*/
protected $defer = true;

/**
* boot a service.
*
* @author yansongda <me@yansongda.cn>
*
* @version 2017-08-20
*
* @return [type] [description]
*/
public function boot()
{
if (!file_exists(config_path('pay.php'))) {
$this->publishes([
dirname(__DIR__) . '/config/pay.php' => config_path('pay.php'),
], 'config');
}


}

/**
* 在容器中注册绑定.
*
* @return void
*/
public function register()
{
$this->mergeConfigFrom(dirname(__DIR__).'/config/pay.php', 'pay');

$this->app->singleton(Pay::class, function ($app) {
return new Pay(config('pay'));
});

$this->app->alias(Pay::class, 'pay');
}

/**
* 获取提供者提供的服务.
*
* @return array
*/
public function provides()
{
return [Pay::class, 'pay'];
}
}

0 comments on commit 21f26e2

Please sign in to comment.