2021-06-29 18:16:11 +08:00
|
|
|
|
<p align="center">
|
2024-02-01 18:23:53 +08:00
|
|
|
|
<a href="https://pay.yansongda.cn" target="_blank" rel="noopener noreferrer"><img width="200" src="https://cdn.jsdelivr.net/gh/yansongda/pay/web/public/images/logo.png" alt="Logo"></a>
|
2021-06-29 18:16:11 +08:00
|
|
|
|
</p>
|
2017-08-09 08:54:15 +08:00
|
|
|
|
|
2021-06-29 18:16:11 +08:00
|
|
|
|
<p align="center">
|
2022-08-17 14:15:40 +08:00
|
|
|
|
<a href="https://codecov.io/gh/yansongda/pay" ><img src="https://codecov.io/gh/yansongda/pay/branch/master/graph/badge.svg?token=tYMV0YT5jj"/></a>
|
2021-08-17 10:55:30 +08:00
|
|
|
|
<a href="https://scrutinizer-ci.com/g/yansongda/pay/?branch=master"><img src="https://scrutinizer-ci.com/g/yansongda/pay/badges/quality-score.png?b=master" alt="scrutinizer"></a>
|
|
|
|
|
<a href="https://github.com/yansongda/pay/actions"><img src="https://github.com/yansongda/pay/workflows/Tester/badge.svg" alt="Tester Status"></a>
|
2023-07-03 14:00:56 +08:00
|
|
|
|
<a href="https://github.com/yansongda/pay/actions"><img src="https://github.com/yansongda/pay/workflows/Code%20Coverage/badge.svg" alt="Code Coverage Status"></a>
|
|
|
|
|
<a href="https://github.com/yansongda/pay/actions"><img src="https://github.com/yansongda/pay/workflows/Coding%20Style/badge.svg" alt="Coding Style Status"></a>
|
2021-08-17 10:55:30 +08:00
|
|
|
|
<a href="https://packagist.org/packages/yansongda/pay"><img src="https://poser.pugx.org/yansongda/pay/v/stable" alt="Stable Version"></a>
|
|
|
|
|
<a href="https://packagist.org/packages/yansongda/pay"><img src="https://poser.pugx.org/yansongda/pay/downloads" alt="Total Downloads"></a>
|
|
|
|
|
<a href="https://packagist.org/packages/yansongda/pay"><img src="https://poser.pugx.org/yansongda/pay/license" alt="License"></a>
|
2021-01-10 01:21:53 +08:00
|
|
|
|
</p>
|
|
|
|
|
|
2021-07-01 14:22:02 +08:00
|
|
|
|
## 前言
|
2017-08-15 15:59:22 +08:00
|
|
|
|
|
2021-07-04 22:57:21 +08:00
|
|
|
|
v3 版与 v2 版在底层有很大的不同,基础架构做了重新的设计,更易扩展,使用起来更方便。
|
|
|
|
|
|
2021-07-01 14:22:02 +08:00
|
|
|
|
开发了多次支付宝与微信支付后,很自然产生一种反感,惰性又来了,想在网上找相关的轮子,可是一直没有找到一款自己觉得逞心如意的,要么使用起来太难理解,要么文件结构太杂乱,只有自己撸起袖子干了。
|
2017-09-20 13:01:56 +08:00
|
|
|
|
|
2017-08-16 10:41:13 +08:00
|
|
|
|
欢迎 Star,欢迎 PR!
|
2017-08-15 15:59:22 +08:00
|
|
|
|
|
2021-07-10 18:32:37 +08:00
|
|
|
|
hyperf 扩展包请 [传送至这里](https://github.com/yansongda/hyperf-pay)
|
|
|
|
|
|
2017-08-20 18:36:15 +08:00
|
|
|
|
laravel 扩展包请 [传送至这里](https://github.com/yansongda/laravel-pay)
|
2021-06-29 18:16:11 +08:00
|
|
|
|
|
2020-03-19 18:19:26 +08:00
|
|
|
|
yii 扩展包请 [传送至这里](https://github.com/guanguans/yii-pay)
|
2017-08-20 18:36:15 +08:00
|
|
|
|
|
2017-08-16 10:41:13 +08:00
|
|
|
|
## 特点
|
2021-06-29 18:16:11 +08:00
|
|
|
|
|
2021-07-04 22:57:21 +08:00
|
|
|
|
- 多租户支持
|
2021-07-15 10:14:06 +08:00
|
|
|
|
- Swoole 支持
|
2021-07-01 14:22:02 +08:00
|
|
|
|
- 灵活的插件机制
|
2018-12-12 20:47:07 +08:00
|
|
|
|
- 丰富的事件系统
|
2017-08-16 10:41:13 +08:00
|
|
|
|
- 命名不那么乱七八糟
|
|
|
|
|
- 隐藏开发者不需要关注的细节
|
|
|
|
|
- 根据支付宝、微信最新 API 开发而成
|
|
|
|
|
- 高度抽象的类,免去各种拼json与xml的痛苦
|
|
|
|
|
- 文件结构清晰易理解,可以随心所欲添加本项目中没有的支付网关
|
|
|
|
|
- 方法使用更优雅,不必再去研究那些奇怪的的方法名或者类名是做啥用的
|
2021-07-17 13:09:34 +08:00
|
|
|
|
- 内置自动获取微信公共证书方法,再也不用再费劲去考虑第一次获取证书的的问题了
|
2022-03-05 21:59:11 +08:00
|
|
|
|
- 符合 PSR2、PSR3、PSR4、PSR7、PSR11、PSR14、PSR18 等各项标准,你可以各种方便的与你的框架集成
|
2017-08-15 15:59:22 +08:00
|
|
|
|
|
2024-02-01 18:23:53 +08:00
|
|
|
|
## 版本计划
|
2017-08-15 15:59:22 +08:00
|
|
|
|
|
2024-02-01 18:23:53 +08:00
|
|
|
|
[https://pay.yansongda.cn/docs/v3/overview/planning](https://pay.yansongda.cn/docs/v3/overview/planning)
|
2023-06-10 16:59:17 +08:00
|
|
|
|
|
2021-07-01 14:22:02 +08:00
|
|
|
|
## 详细文档
|
|
|
|
|
|
|
|
|
|
[https://pay.yansongda.cn](https://pay.yansongda.cn)
|
|
|
|
|
|
2021-07-01 14:34:33 +08:00
|
|
|
|
## 支持的支付方法
|
2021-07-01 14:22:02 +08:00
|
|
|
|
|
2022-09-17 00:45:33 +08:00
|
|
|
|
yansongda/pay 100% 兼容 支付宝/微信/银联 所有功能(包括服务商功能),只需通过「插件机制」引入即可。
|
2021-07-01 14:22:02 +08:00
|
|
|
|
|
2021-08-28 21:16:42 +08:00
|
|
|
|
同时,SDK 直接支持内置了以下插件,详情请查阅文档。
|
2021-07-01 14:22:02 +08:00
|
|
|
|
|
|
|
|
|
### 支付宝
|
2021-08-28 21:16:42 +08:00
|
|
|
|
|
2017-12-25 17:49:19 +08:00
|
|
|
|
- 电脑支付
|
|
|
|
|
- 手机网站支付
|
|
|
|
|
- APP 支付
|
|
|
|
|
- 刷卡支付
|
|
|
|
|
- 扫码支付
|
2017-12-25 21:58:37 +08:00
|
|
|
|
- 账户转账
|
2018-12-18 10:45:03 +08:00
|
|
|
|
- 小程序支付
|
2021-07-01 14:22:02 +08:00
|
|
|
|
- ...
|
2017-12-13 17:42:16 +08:00
|
|
|
|
|
2021-07-01 14:22:02 +08:00
|
|
|
|
### 微信
|
2021-08-28 21:16:42 +08:00
|
|
|
|
|
2017-12-25 17:49:19 +08:00
|
|
|
|
- 公众号支付
|
|
|
|
|
- 小程序支付
|
|
|
|
|
- H5 支付
|
|
|
|
|
- 扫码支付
|
|
|
|
|
- APP 支付
|
2023-05-21 23:02:32 +08:00
|
|
|
|
- 刷卡支付
|
2021-07-01 14:22:02 +08:00
|
|
|
|
- ...
|
2017-12-25 17:49:19 +08:00
|
|
|
|
|
2022-09-17 00:45:33 +08:00
|
|
|
|
### 银联
|
|
|
|
|
|
|
|
|
|
- 手机网站支付
|
|
|
|
|
- 电脑网站支付
|
|
|
|
|
- 刷卡支付
|
|
|
|
|
- 扫码支付
|
|
|
|
|
- ...
|
2024-06-22 10:21:34 +08:00
|
|
|
|
-
|
|
|
|
|
### 江苏银行(e融支付)
|
|
|
|
|
|
|
|
|
|
- 聚合扫码支付(微信,支付宝,银联,e融)
|
|
|
|
|
- ...
|
2022-09-17 00:45:33 +08:00
|
|
|
|
|
2017-12-25 17:49:19 +08:00
|
|
|
|
## 安装
|
|
|
|
|
```shell
|
2024-04-27 22:02:22 +08:00
|
|
|
|
composer require yansongda/pay:~3.7.0 -vvv
|
2017-12-25 17:49:19 +08:00
|
|
|
|
```
|
|
|
|
|
|
2021-06-29 18:59:23 +08:00
|
|
|
|
## 深情一撇
|
2017-12-25 17:49:19 +08:00
|
|
|
|
|
2017-12-25 21:58:37 +08:00
|
|
|
|
### 支付宝
|
2017-12-13 17:42:16 +08:00
|
|
|
|
```php
|
2017-12-25 17:49:19 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
|
|
use Yansongda\Pay\Pay;
|
|
|
|
|
|
2021-07-01 14:22:02 +08:00
|
|
|
|
class AlipayController
|
2017-12-25 17:49:19 +08:00
|
|
|
|
{
|
|
|
|
|
protected $config = [
|
2021-06-04 11:34:45 +08:00
|
|
|
|
'alipay' => [
|
|
|
|
|
'default' => [
|
2021-12-26 13:04:46 +08:00
|
|
|
|
// 必填-支付宝分配的 app_id
|
2021-06-04 11:34:45 +08:00
|
|
|
|
'app_id' => '2016082000295641',
|
2021-12-26 13:04:46 +08:00
|
|
|
|
// 必填-应用私钥 字符串或路径
|
|
|
|
|
'app_secret_cert' => '89iZ2iC16H6/6a3YcP+hDZUjiNGQx9cuwi9eJyykvcwhD...',
|
|
|
|
|
// 必填-应用公钥证书 路径
|
|
|
|
|
'app_public_cert_path' => '/Users/yansongda/pay/cert/appCertPublicKey_2016082000295641.crt',
|
|
|
|
|
// 必填-支付宝公钥证书 路径
|
|
|
|
|
'alipay_public_cert_path' => '/Users/yansongda/pay/cert/alipayCertPublicKey_RSA2.crt',
|
|
|
|
|
// 必填-支付宝根证书 路径
|
|
|
|
|
'alipay_root_cert_path' => '/Users/yansongda/pay/cert/alipayRootCert.crt',
|
|
|
|
|
'return_url' => 'https://yansongda.cn/alipay/return',
|
|
|
|
|
'notify_url' => 'https://yansongda.cn/alipay/notify',
|
2022-11-08 20:53:20 +08:00
|
|
|
|
// 选填-第三方应用授权token
|
|
|
|
|
'app_auth_token' => '',
|
2021-12-26 13:04:46 +08:00
|
|
|
|
// 选填-服务商模式下的服务商 id,当 mode 为 Pay::MODE_SERVICE 时使用该参数
|
|
|
|
|
'service_provider_id' => '',
|
|
|
|
|
// 选填-默认为正常模式。可选为: MODE_NORMAL, MODE_SANDBOX, MODE_SERVICE
|
|
|
|
|
'mode' => Pay::MODE_NORMAL,
|
2021-06-04 11:34:45 +08:00
|
|
|
|
],
|
|
|
|
|
],
|
2021-07-01 14:22:02 +08:00
|
|
|
|
'logger' => [ // optional
|
2021-06-29 18:59:23 +08:00
|
|
|
|
'enable' => false,
|
2017-12-25 21:58:37 +08:00
|
|
|
|
'file' => './logs/alipay.log',
|
2018-09-13 11:08:08 +08:00
|
|
|
|
'level' => 'info', // 建议生产环境等级调整为 info,开发环境为 debug
|
2018-09-03 17:05:17 +08:00
|
|
|
|
'type' => 'single', // optional, 可选 daily.
|
|
|
|
|
'max_file' => 30, // optional, 当 type 为 daily 时有效,默认 30 天
|
2017-12-25 17:49:19 +08:00
|
|
|
|
],
|
2018-09-13 21:16:31 +08:00
|
|
|
|
'http' => [ // optional
|
|
|
|
|
'timeout' => 5.0,
|
|
|
|
|
'connect_timeout' => 5.0,
|
|
|
|
|
// 更多配置项请参考 [Guzzle](https://guzzle-cn.readthedocs.io/zh_CN/latest/request-options.html)
|
|
|
|
|
],
|
2017-12-25 17:49:19 +08:00
|
|
|
|
];
|
|
|
|
|
|
2021-06-29 18:59:23 +08:00
|
|
|
|
public function web()
|
2017-12-25 17:49:19 +08:00
|
|
|
|
{
|
2021-07-01 14:22:02 +08:00
|
|
|
|
$result = Pay::alipay($this->config)->web([
|
2021-06-29 18:59:23 +08:00
|
|
|
|
'out_trade_no' => ''.time(),
|
|
|
|
|
'total_amount' => '0.01',
|
2021-07-01 14:22:02 +08:00
|
|
|
|
'subject' => 'yansongda 测试 - 1',
|
2021-06-29 18:59:23 +08:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
return $result;
|
2017-12-25 17:49:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-01 14:22:02 +08:00
|
|
|
|
public function returnCallback()
|
2017-12-25 17:49:19 +08:00
|
|
|
|
{
|
2021-07-01 14:22:02 +08:00
|
|
|
|
$data = Pay::alipay($this->config)->callback(); // 是的,验签就这么简单!
|
2017-12-25 17:49:19 +08:00
|
|
|
|
|
2017-12-25 21:58:37 +08:00
|
|
|
|
// 订单号:$data->out_trade_no
|
|
|
|
|
// 支付宝交易号:$data->trade_no
|
|
|
|
|
// 订单总金额:$data->total_amount
|
2017-12-25 17:49:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-01 14:22:02 +08:00
|
|
|
|
public function notifyCallback()
|
2017-12-25 17:49:19 +08:00
|
|
|
|
{
|
2017-12-25 21:58:37 +08:00
|
|
|
|
$alipay = Pay::alipay($this->config);
|
|
|
|
|
|
|
|
|
|
try{
|
2021-07-01 14:22:02 +08:00
|
|
|
|
$data = $alipay->callback(); // 是的,验签就这么简单!
|
2017-12-25 21:58:37 +08:00
|
|
|
|
|
|
|
|
|
// 请自行对 trade_status 进行判断及其它逻辑进行判断,在支付宝的业务通知中,只有交易通知状态为 TRADE_SUCCESS 或 TRADE_FINISHED 时,支付宝才会认定为买家付款成功。
|
|
|
|
|
// 1、商户需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号;
|
|
|
|
|
// 2、判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额);
|
|
|
|
|
// 3、校验通知中的seller_id(或者seller_email) 是否为out_trade_no这笔单据的对应的操作方(有的时候,一个商户可能有多个seller_id/seller_email);
|
|
|
|
|
// 4、验证app_id是否为该商户本身。
|
2017-12-25 17:49:19 +08:00
|
|
|
|
// 5、其它业务逻辑情况
|
2018-12-07 14:26:29 +08:00
|
|
|
|
} catch (\Exception $e) {
|
2017-12-25 21:58:37 +08:00
|
|
|
|
// $e->getMessage();
|
2017-12-25 17:49:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-01 14:22:02 +08:00
|
|
|
|
return $alipay->success();
|
2017-12-25 17:49:19 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
2017-12-25 21:58:37 +08:00
|
|
|
|
|
|
|
|
|
### 微信
|
2017-12-25 17:49:19 +08:00
|
|
|
|
```php
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
2017-12-13 17:42:16 +08:00
|
|
|
|
use Yansongda\Pay\Pay;
|
2017-12-25 17:49:19 +08:00
|
|
|
|
|
2021-07-01 14:22:02 +08:00
|
|
|
|
class WechatController
|
2017-12-25 17:49:19 +08:00
|
|
|
|
{
|
|
|
|
|
protected $config = [
|
2021-07-01 14:22:02 +08:00
|
|
|
|
'wechat' => [
|
|
|
|
|
'default' => [
|
2022-11-08 20:53:20 +08:00
|
|
|
|
// 必填-商户号
|
2021-07-01 14:22:02 +08:00
|
|
|
|
'mch_id' => '',
|
2023-05-21 23:02:32 +08:00
|
|
|
|
// 选填-v2商户私钥
|
|
|
|
|
'mch_secret_key_v2' => '',
|
|
|
|
|
// 必填-v3商户秘钥
|
2021-07-01 14:22:02 +08:00
|
|
|
|
'mch_secret_key' => '',
|
2021-12-26 13:04:46 +08:00
|
|
|
|
// 必填-商户私钥 字符串或路径
|
2021-07-01 14:22:02 +08:00
|
|
|
|
'mch_secret_cert' => '',
|
2021-12-26 13:04:46 +08:00
|
|
|
|
// 必填-商户公钥证书路径
|
2021-07-01 14:22:02 +08:00
|
|
|
|
'mch_public_cert_path' => '',
|
2021-12-26 13:04:46 +08:00
|
|
|
|
// 必填
|
|
|
|
|
'notify_url' => 'https://yansongda.cn/wechat/notify',
|
|
|
|
|
// 选填-公众号 的 app_id
|
2022-11-08 20:53:20 +08:00
|
|
|
|
'mp_app_id' => '',
|
2021-12-26 13:04:46 +08:00
|
|
|
|
// 选填-小程序 的 app_id
|
|
|
|
|
'mini_app_id' => '',
|
|
|
|
|
// 选填-app 的 app_id
|
|
|
|
|
'app_id' => '',
|
|
|
|
|
// 选填-服务商模式下,子公众号 的 app_id
|
|
|
|
|
'sub_mp_app_id' => '',
|
|
|
|
|
// 选填-服务商模式下,子 app 的 app_id
|
|
|
|
|
'sub_app_id' => '',
|
|
|
|
|
// 选填-服务商模式下,子小程序 的 app_id
|
|
|
|
|
'sub_mini_app_id' => '',
|
|
|
|
|
// 选填-服务商模式下,子商户id
|
|
|
|
|
'sub_mch_id' => '',
|
2022-11-08 20:53:20 +08:00
|
|
|
|
// 选填-微信平台公钥证书路径, optional,强烈建议 php-fpm 模式下配置此参数
|
2021-07-17 13:09:34 +08:00
|
|
|
|
'wechat_public_cert_path' => [
|
2022-11-08 20:53:20 +08:00
|
|
|
|
'45F59D4DABF31918AFCEC556D5D2C6E376675D57' => __DIR__.'/Cert/wechatpay_45F***D57.pem',
|
2021-07-17 13:09:34 +08:00
|
|
|
|
],
|
2021-12-26 13:04:46 +08:00
|
|
|
|
// 选填-默认为正常模式。可选为: MODE_NORMAL, MODE_SERVICE
|
|
|
|
|
'mode' => Pay::MODE_NORMAL,
|
2021-07-01 14:22:02 +08:00
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'logger' => [ // optional
|
|
|
|
|
'enable' => false,
|
2017-12-25 21:58:37 +08:00
|
|
|
|
'file' => './logs/wechat.log',
|
2018-09-13 11:08:08 +08:00
|
|
|
|
'level' => 'info', // 建议生产环境等级调整为 info,开发环境为 debug
|
2018-09-11 11:37:35 +08:00
|
|
|
|
'type' => 'single', // optional, 可选 daily.
|
|
|
|
|
'max_file' => 30, // optional, 当 type 为 daily 时有效,默认 30 天
|
2017-12-25 17:49:19 +08:00
|
|
|
|
],
|
2018-09-13 21:16:31 +08:00
|
|
|
|
'http' => [ // optional
|
|
|
|
|
'timeout' => 5.0,
|
|
|
|
|
'connect_timeout' => 5.0,
|
|
|
|
|
// 更多配置项请参考 [Guzzle](https://guzzle-cn.readthedocs.io/zh_CN/latest/request-options.html)
|
|
|
|
|
],
|
2017-12-25 17:49:19 +08:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
2017-12-25 21:58:37 +08:00
|
|
|
|
$order = [
|
2022-01-18 11:40:07 +08:00
|
|
|
|
'out_trade_no' => time().'',
|
|
|
|
|
'description' => 'subject-测试',
|
|
|
|
|
'amount' => [
|
|
|
|
|
'total' => 1,
|
|
|
|
|
],
|
|
|
|
|
'payer' => [
|
|
|
|
|
'openid' => 'onkVf1FjWS5SBxxxxxxxx',
|
|
|
|
|
],
|
2017-12-25 17:49:19 +08:00
|
|
|
|
];
|
|
|
|
|
|
2017-12-25 21:58:37 +08:00
|
|
|
|
$pay = Pay::wechat($this->config)->mp($order);
|
2017-12-25 17:49:19 +08:00
|
|
|
|
|
2017-12-25 21:58:37 +08:00
|
|
|
|
// $pay->appId
|
|
|
|
|
// $pay->timeStamp
|
|
|
|
|
// $pay->nonceStr
|
|
|
|
|
// $pay->package
|
|
|
|
|
// $pay->signType
|
2017-12-25 17:49:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-01 14:22:02 +08:00
|
|
|
|
public function notifyCallback()
|
2017-12-25 17:49:19 +08:00
|
|
|
|
{
|
2017-12-25 21:58:37 +08:00
|
|
|
|
$pay = Pay::wechat($this->config);
|
2017-12-25 17:49:19 +08:00
|
|
|
|
|
2017-12-25 21:58:37 +08:00
|
|
|
|
try{
|
2021-07-01 14:22:02 +08:00
|
|
|
|
$data = $pay->callback(); // 是的,验签就这么简单!
|
2018-12-07 14:26:29 +08:00
|
|
|
|
} catch (\Exception $e) {
|
2017-12-25 21:58:37 +08:00
|
|
|
|
// $e->getMessage();
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-01 14:22:02 +08:00
|
|
|
|
return $pay->success();
|
2017-12-25 17:49:19 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2024-06-22 10:21:34 +08:00
|
|
|
|
### 江苏银行(e融支付)
|
|
|
|
|
```php
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
|
|
use Yansongda\Pay\Pay;
|
|
|
|
|
|
|
|
|
|
class EpayController
|
|
|
|
|
{
|
|
|
|
|
protected $config = [
|
|
|
|
|
'jsb' => [
|
|
|
|
|
'default' => [
|
|
|
|
|
// 服务代码
|
|
|
|
|
'svr_code' => '',
|
|
|
|
|
// 必填-合作商ID
|
|
|
|
|
'partner_id' => '',
|
|
|
|
|
// 必填-公私钥对编号
|
|
|
|
|
'public_key_code' => '00',
|
|
|
|
|
// 必填-商户私钥(加密签名)
|
|
|
|
|
'mch_secret_cert_path' => '',
|
|
|
|
|
// 必填-商户公钥证书路径(提供江苏银行进行验证签名用)
|
|
|
|
|
'mch_public_cert_path' => '',
|
|
|
|
|
// 必填-江苏银行的公钥(用于解密江苏银行返回的数据)
|
|
|
|
|
'jsb_public_cert_path' => '',
|
|
|
|
|
//支付通知地址
|
|
|
|
|
'notify_url' => '',
|
|
|
|
|
// 选填-默认为正常模式。可选为: MODE_NORMAL:正式环境, MODE_SANDBOX:测试环境
|
|
|
|
|
'mode' => Pay::MODE_NORMAL,
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'logger' => [ // optional
|
|
|
|
|
'enable' => false,
|
|
|
|
|
'file' => './logs/epay.log',
|
|
|
|
|
'level' => 'info', // 建议生产环境等级调整为 info,开发环境为 debug
|
|
|
|
|
'type' => 'single', // optional, 可选 daily.
|
|
|
|
|
'max_file' => 30, // optional, 当 type 为 daily 时有效,默认 30 天
|
|
|
|
|
],
|
|
|
|
|
'http' => [ // optional
|
|
|
|
|
'timeout' => 5.0,
|
|
|
|
|
'connect_timeout' => 5.0,
|
|
|
|
|
// 更多配置项请参考 [Guzzle](https://guzzle-cn.readthedocs.io/zh_CN/latest/request-options.html)
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
|
|
|
|
$order = [
|
|
|
|
|
'outTradeNo' => time().'',
|
|
|
|
|
'proInfo' => 'subject-测试',
|
|
|
|
|
'totalFee'=> 1,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$pay = Pay::jsb($this->config)->scan($order);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function notifyCallback()
|
|
|
|
|
{
|
|
|
|
|
$pay = Pay::jsb($this->config);
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
$data = $pay->callback(); // 是的,验签就这么简单!
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
// $e->getMessage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $pay->success();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2017-08-16 12:53:00 +08:00
|
|
|
|
## 代码贡献
|
2021-06-29 18:59:23 +08:00
|
|
|
|
|
2024-06-22 10:21:34 +08:00
|
|
|
|
由于测试及使用环境的限制,本项目中只开发了「支付宝」、「微信支付」、「银联」、「江苏银行」的相关支付网关。
|
2017-08-16 12:53:00 +08:00
|
|
|
|
|
|
|
|
|
如果您有其它支付网关的需求,或者发现本项目中需要改进的代码,**_欢迎 Fork 并提交 PR!_**
|
2017-08-09 09:05:17 +08:00
|
|
|
|
|
2018-12-12 20:04:09 +08:00
|
|
|
|
## 赏一杯咖啡吧
|
|
|
|
|
|
2024-02-01 18:23:53 +08:00
|
|
|
|
![pay](https://cdn.jsdelivr.net/gh/yansongda/pay/web/public/images/pay.jpg)
|
2018-12-12 20:04:09 +08:00
|
|
|
|
|
2017-08-09 09:05:17 +08:00
|
|
|
|
## LICENSE
|
2021-06-29 18:59:23 +08:00
|
|
|
|
|
2018-12-07 14:26:29 +08:00
|
|
|
|
MIT
|