You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.1 KiB
97 lines
2.1 KiB
3 weeks ago
|
# Unify-Payment
|
||
|
|
||
|
方鼎统一支付平台v2,PHP接入版
|
||
|
|
||
|
## 使用
|
||
|
|
||
|
php环境需 >= 7.4
|
||
|
|
||
|
### Composer 安装
|
||
|
|
||
|
1. composer.json 的 repositories 项添加本地文件夹路径
|
||
|
```json
|
||
|
{
|
||
|
"repositories": [
|
||
|
{
|
||
|
"type": "path",
|
||
|
"url": "./unify_payment"
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
```
|
||
|
|
||
|
2. 执行require命令
|
||
|
|
||
|
```bash
|
||
|
$ composer require fd_wechat/unify_payment
|
||
|
```
|
||
|
|
||
|
## 基本用法
|
||
|
|
||
|
### 支付模块
|
||
|
|
||
|
#### miniClient / officialClient
|
||
|
```php
|
||
|
<?php
|
||
|
require_once 'vendor/autoload.php';
|
||
|
|
||
|
use UnifyPayment\Factory;
|
||
|
use UnifyPayment\Cores\Struct\CreateWeChatOrder;
|
||
|
|
||
|
$order = new CreateOrder('当天挂号', 'FD2022080310000055123451223', 0.01, '1', '002197|测试', 'A', 'ovIGQwOy1e-Zptyug20l5hqI0P5Q', 'https://www.test.com');
|
||
|
|
||
|
// 小程序支付
|
||
|
Factory::pay($config)->mini->jsapi($order);
|
||
|
|
||
|
// 公众号支付
|
||
|
Factory::pay($config)->official->jsapi($order);
|
||
|
|
||
|
```
|
||
|
|
||
|
### 通用模块
|
||
|
|
||
|
#### orderClient
|
||
|
```php
|
||
|
<?php
|
||
|
require_once 'vendor/autoload.php';
|
||
|
|
||
|
use UnifyPayment\Factory;
|
||
|
use UnifyPayment\Cores\Struct\QueryOrder;
|
||
|
use UnifyPayment\Cores\Struct\CloseOrder;
|
||
|
use UnifyPayment\Cores\Struct\RefundOrder;
|
||
|
use UnifyPayment\Cores\Struct\ConfirmOrderForEx;
|
||
|
|
||
|
// 订单查询
|
||
|
$order = new QueryOrder('FD2022080310000055123451223');
|
||
|
Factory::common($config)->order->query($order);
|
||
|
|
||
|
// 订单关闭
|
||
|
$order = new CloseOrder('FD2022080310000055123451223');
|
||
|
Factory::common($config)->order->close($order);
|
||
|
|
||
|
// 订单退款
|
||
|
$order = new RefundOrder('FD2022080310000055123451223', 'FD2022080310000055123451223_12345', 0.01, 'Test Refund');
|
||
|
Factory::common($config)->order->refund($order);
|
||
|
|
||
|
// 外部订单确认
|
||
|
$order = new ConfirmOrderForEx('FD2022080310000055123451223', 'ZSD0002974832', 'ow8NuxN_ALO2MzSvzj19hyxWjCVY', '4200067674202302063709953797');
|
||
|
Factory::common($config)->order->confirmForEx($order);
|
||
|
|
||
|
```
|
||
|
|
||
|
### 添加第三方Client
|
||
|
```php
|
||
|
$app = Factory::pay($config);
|
||
|
$app->registerOtherClient('other', OtherClient::class);
|
||
|
$app->other->doSomeThing(...);
|
||
|
```
|
||
|
|
||
|
### 数据Mock
|
||
|
|
||
|
Mock数据类在目录 `./src/Mock` 下
|
||
|
|
||
|
```php
|
||
|
|
||
|
$mockHandler = new CreateWeChatOrderHandler(true);
|
||
|
Factory::pay($config)->official->setMockHandler([$mockHandler])->jsapi($order);
|
||
|
```
|