main 2.3.0
liuzhaobo 1 year ago
commit 1218435448

3
.gitignore vendored

@ -0,0 +1,3 @@
vendor/
composer.lock
.idea

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2017 yansongda <me@yansongda.cn>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -0,0 +1,96 @@
该文档为 v2.x 版本
## 运行环境
- php >= 7.0
- composer
- laravel || lumen >= 5.1
## 安装
```Shell
$ composer require yansongda/laravel-pay
```
### 添加 service provideroptional. if laravel < 5.5 || lumen
```PHP
// laravel < 5.5
Yansongda\LaravelPay\PayServiceProvider::class,
// lumen
$app->register(Yansongda\LaravelPay\PayServiceProvider::class);
```
### 添加 aliasoptional. if laravel < 5.5
```PHP
'Pay' => Yansongda\LaravelPay\Facades\Pay::class,
```
### 配置文件
```Shell
$ php artisan vendor:publish --provider="Yansongda\LaravelPay\PayServiceProvider" --tag=laravel-pay
```
**lumen 用户请手动复制**
随后,请在 `config` 文件夹中完善配置信息。
`.env` 文件里面配置
```PHP
# alipay 配置
ALI_APP_ID=
ALI_PUBLIC_KEY=
ALI_PRIVATE_KEY=
# wechat 配置
WECHAT_APP_ID=
WECHAT_MINIAPP_ID=
WECHAT_APPID=
WECHAT_MCH_ID=
WECHAT_KEY=
```
## 使用方法
### 支付宝
```PHP
use Pay;
$order = [
'out_trade_no' => time(),
'total_amount' => '1',
'subject' => 'test subject - 测试',
];
return Pay::alipay()->web($order);
// 下面这个方法也可以
// return Pay::web($order);
```
### 微信
```PHP
use Pay;
$order = [
'out_trade_no' => time(),
'body' => 'subject-测试',
'total_fee' => '1',
'openid' => 'onkVf1FjWS5SBIixxxxxxxxx',
];
$result = Pay::wechat()->mp($order);
```
具体使用说明请传送至 [https://github.com/yansongda/pay](https://github.com/yansongda/pay)
## License
MIT

@ -0,0 +1,35 @@
{
"name": "feizhiyi/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": "feizhiyi",
"email": "me@feizhiyi.cn"
}
],
"require": {
"illuminate/support": "^5.1 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0",
"yansongda/pay": "^2.0"
},
"autoload": {
"psr-4": {
"Yansongda\\LaravelPay\\": "src"
}
},
"extra": {
"laravel": {
"providers": [
"Yansongda\\LaravelPay\\PayServiceProvider"
],
"aliases": {
"Pay": "Yansongda\\LaravelPay\\Facades\\Pay"
}
}
},
"license": "MIT"
}

@ -0,0 +1,77 @@
<?php
return [
'alipay' => [
// 支付宝分配的 APPID
'app_id' => env('ALI_APP_ID', ''),
// 支付宝异步通知地址
'notify_url' => '',
// 支付成功后同步通知地址
'return_url' => '',
// 阿里公共密钥,验证签名时使用
'ali_public_key' => env('ALI_PUBLIC_KEY', ''),
// 自己的私钥,签名时使用
'private_key' => env('ALI_PRIVATE_KEY', ''),
// 使用公钥证书模式,请配置下面两个参数,同时修改 ali_public_key 为以 .crt 结尾的支付宝公钥证书路径,如(./cert/alipayCertPublicKey_RSA2.crt
// 应用公钥证书路径
// 'app_cert_public_key' => './cert/appCertPublicKey.crt',
// 支付宝根证书路径
// 'alipay_root_cert' => './cert/alipayRootCert.crt',
// optional默认 warning日志路径为sys_get_temp_dir().'/logs/yansongda.pay.log'
'log' => [
'file' => storage_path('logs/alipay.log'),
// 'level' => 'debug'
// 'type' => 'single', // optional, 可选 daily.
// 'max_file' => 30,
],
// optional设置此参数将进入沙箱模式
// 'mode' => 'dev',
],
'wechat' => [
// 公众号 APPID
'app_id' => env('WECHAT_APP_ID', ''),
// 小程序 APPID
'miniapp_id' => env('WECHAT_MINIAPP_ID', ''),
// APP 引用的 appid
'appid' => env('WECHAT_APPID', ''),
// 微信支付分配的微信商户号
'mch_id' => env('WECHAT_MCH_ID', ''),
// 微信支付异步通知地址
'notify_url' => '',
// 微信支付签名秘钥
'key' => env('WECHAT_KEY', ''),
// 客户端证书路径退款、红包等需要用到。请填写绝对路径linux 请确保权限问题。pem 格式。
'cert_client' => '',
// 客户端秘钥路径退款、红包等需要用到。请填写绝对路径linux 请确保权限问题。pem 格式。
'cert_key' => '',
// optional默认 warning日志路径为sys_get_temp_dir().'/logs/yansongda.pay.log'
'log' => [
'file' => storage_path('logs/wechat.log'),
// 'level' => 'debug'
// 'type' => 'single', // optional, 可选 daily.
// 'max_file' => 30,
],
// optional
// 'dev' 时为沙箱模式
// 'hk' 时为东南亚节点
// 'mode' => 'dev',
],
];

@ -0,0 +1,40 @@
<?php
namespace Yansongda\LaravelPay\Facades;
use Illuminate\Support\Facades\Facade;
use Yansongda\Pay\Gateways\Alipay;
use Yansongda\Pay\Gateways\Wechat;
class Pay extends Facade
{
/**
* Return the facade accessor.
*
* @return string
*/
public static function getFacadeAccessor()
{
return 'pay.alipay';
}
/**
* Return the facade accessor.
*
* @return Alipay
*/
public static function alipay()
{
return app('pay.alipay');
}
/**
* Return the facade accessor.
*
* @return Wechat
*/
public static function wechat()
{
return app('pay.wechat');
}
}

@ -0,0 +1,66 @@
<?php
namespace Yansongda\LaravelPay;
use Illuminate\Foundation\Application as LaravelApplication;
use Illuminate\Support\ServiceProvider;
use Laravel\Lumen\Application as LumenApplication;
use Yansongda\Pay\Pay;
class PayServiceProvider extends ServiceProvider
{
/**
* If is defer.
*
* @var bool
*/
protected $defer = true;
/**
* Boot the service.
*
* @author yansongda <me@yansongda.cn>
*/
public function boot()
{
if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
$this->publishes([
dirname(__DIR__).'/config/pay.php' => config_path('pay.php'), ],
'laravel-pay'
);
} elseif ($this->app instanceof LumenApplication) {
$this->app->configure('pay');
}
}
/**
* Register the service.
*
* @author yansongda <me@yansongda.cn>
*
* @return void
*/
public function register()
{
$this->mergeConfigFrom(dirname(__DIR__).'/config/pay.php', 'pay');
$this->app->singleton('pay.alipay', function () {
return Pay::alipay(config('pay.alipay'));
});
$this->app->singleton('pay.wechat', function () {
return Pay::wechat(config('pay.wechat'));
});
}
/**
* Get services.
*
* @author yansongda <me@yansongda.cn>
*
* @return array
*/
public function provides()
{
return ['pay.alipay', 'pay.wechat'];
}
}
Loading…
Cancel
Save