mirror of
https://gitee.com/yansongda/pay.git
synced 2024-11-30 03:07:38 +08:00
parent
8e9806996e
commit
c581fb6db7
22
CHANGELOG.md
22
CHANGELOG.md
@ -1,48 +1,54 @@
|
||||
## v3.0.9
|
||||
|
||||
### added
|
||||
|
||||
- feat: 支持直连商户批量转账到零钱 (#501)
|
||||
|
||||
## v3.0.8
|
||||
|
||||
## fixed
|
||||
### fixed
|
||||
|
||||
- fix: 设置 bcscale 时支付宝根证书计算错误的问题 (#492, #494)
|
||||
|
||||
## v3.0.7
|
||||
|
||||
## fixed
|
||||
### fixed
|
||||
|
||||
- fix: 支付宝 wap/web 支付 get 方法时url拼接问题 (#488)
|
||||
|
||||
## v3.0.6
|
||||
|
||||
## optimized
|
||||
### optimized
|
||||
|
||||
- chore: 优化服务商模式小程序下单场景 (#487)
|
||||
|
||||
## v3.0.5
|
||||
|
||||
## fixed
|
||||
### fixed
|
||||
|
||||
- fix: 服务商模式交易查询 (#483)
|
||||
|
||||
## v3.0.4
|
||||
|
||||
## added
|
||||
### added
|
||||
|
||||
- feat: 支持服务商模式 (#479)
|
||||
- feat: 支持微信服务商分账功能 (#480)
|
||||
|
||||
## v3.0.3
|
||||
|
||||
## added
|
||||
### added
|
||||
|
||||
- feat: 公钥证书增加 cer 后缀支持 (#d22e29a)
|
||||
|
||||
## v3.0.2
|
||||
|
||||
## fixed
|
||||
### fixed
|
||||
|
||||
- 修复微信支付关闭订单时报错问题 (#475)
|
||||
|
||||
## v3.0.1
|
||||
|
||||
## fixed
|
||||
### fixed
|
||||
|
||||
- 修复微信支付关闭订单时报错问题 (#475)
|
||||
|
38
src/Plugin/Wechat/Fund/Balance/QueryDayEndPlugin.php
Normal file
38
src/Plugin/Wechat/Fund/Balance/QueryDayEndPlugin.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Wechat\Fund\Balance;
|
||||
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
|
||||
class QueryDayEndPlugin extends GeneralPlugin
|
||||
{
|
||||
protected function getMethod(): string
|
||||
{
|
||||
return 'GET';
|
||||
}
|
||||
|
||||
protected function doSomething(Rocket $rocket): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Yansongda\Pay\Exception\InvalidParamsException
|
||||
*/
|
||||
protected function getUri(Rocket $rocket): string
|
||||
{
|
||||
$payload = $rocket->getPayload();
|
||||
|
||||
if (is_null($payload->get('account_type')) || is_null($payload->get('date'))) {
|
||||
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
|
||||
}
|
||||
|
||||
return 'v3/merchant/fund/dayendbalance/'.
|
||||
$payload->get('account_type').
|
||||
'?date='.$payload->get('date');
|
||||
}
|
||||
}
|
37
src/Plugin/Wechat/Fund/Balance/QueryPlugin.php
Normal file
37
src/Plugin/Wechat/Fund/Balance/QueryPlugin.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Wechat\Fund\Balance;
|
||||
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
|
||||
class QueryPlugin extends GeneralPlugin
|
||||
{
|
||||
protected function getMethod(): string
|
||||
{
|
||||
return 'GET';
|
||||
}
|
||||
|
||||
protected function doSomething(Rocket $rocket): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Yansongda\Pay\Exception\InvalidParamsException
|
||||
*/
|
||||
protected function getUri(Rocket $rocket): string
|
||||
{
|
||||
$payload = $rocket->getPayload();
|
||||
|
||||
if (is_null($payload->get('account_type'))) {
|
||||
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
|
||||
}
|
||||
|
||||
return 'v3/merchant/fund/balance/'.
|
||||
$payload->get('account_type');
|
||||
}
|
||||
}
|
30
src/Plugin/Wechat/Fund/Transfer/CreateBillReceiptPlugin.php
Normal file
30
src/Plugin/Wechat/Fund/Transfer/CreateBillReceiptPlugin.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
|
||||
class CreateBillReceiptPlugin extends GeneralPlugin
|
||||
{
|
||||
/**
|
||||
* @throws \Yansongda\Pay\Exception\InvalidParamsException
|
||||
*/
|
||||
protected function doSomething(Rocket $rocket): void
|
||||
{
|
||||
$payload = $rocket->getPayload();
|
||||
|
||||
if (is_null($payload->get('out_batch_no'))) {
|
||||
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getUri(Rocket $rocket): string
|
||||
{
|
||||
return 'v3/transfer/bill-receipt';
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
|
||||
class CreateDetailReceiptPlugin extends GeneralPlugin
|
||||
{
|
||||
/**
|
||||
* @throws \Yansongda\Pay\Exception\InvalidParamsException
|
||||
*/
|
||||
protected function doSomething(Rocket $rocket): void
|
||||
{
|
||||
$payload = $rocket->getPayload();
|
||||
|
||||
if (is_null($payload->get('out_detail_no')) || is_null($payload->get('accept_type'))) {
|
||||
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getUri(Rocket $rocket): string
|
||||
{
|
||||
return 'v3/transfer-detail/electronic-receipts';
|
||||
}
|
||||
}
|
32
src/Plugin/Wechat/Fund/Transfer/CreatePlugin.php
Normal file
32
src/Plugin/Wechat/Fund/Transfer/CreatePlugin.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
|
||||
class CreatePlugin extends GeneralPlugin
|
||||
{
|
||||
/**
|
||||
* @throws \Yansongda\Pay\Exception\ContainerDependencyException
|
||||
* @throws \Yansongda\Pay\Exception\ContainerException
|
||||
* @throws \Yansongda\Pay\Exception\ServiceNotFoundException
|
||||
*/
|
||||
protected function doSomething(Rocket $rocket): void
|
||||
{
|
||||
$config = get_wechat_config($rocket->getParams());
|
||||
|
||||
$wechatId = [
|
||||
'appid' => $config->get('mp_app_id'),
|
||||
];
|
||||
|
||||
$rocket->mergePayload($wechatId);
|
||||
}
|
||||
|
||||
protected function getUri(Rocket $rocket): string
|
||||
{
|
||||
return 'v3/transfer/batches';
|
||||
}
|
||||
}
|
37
src/Plugin/Wechat/Fund/Transfer/DownloadReceiptPlugin.php
Normal file
37
src/Plugin/Wechat/Fund/Transfer/DownloadReceiptPlugin.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
|
||||
class DownloadReceiptPlugin extends GeneralPlugin
|
||||
{
|
||||
/**
|
||||
* @throws \Yansongda\Pay\Exception\InvalidParamsException
|
||||
*/
|
||||
protected function getUri(Rocket $rocket): string
|
||||
{
|
||||
$payload = $rocket->getPayload();
|
||||
|
||||
if (is_null($payload->get('download_url'))) {
|
||||
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
|
||||
}
|
||||
|
||||
return $payload->get('download_url');
|
||||
}
|
||||
|
||||
protected function getMethod(): string
|
||||
{
|
||||
return 'GET';
|
||||
}
|
||||
|
||||
protected function doSomething(Rocket $rocket): void
|
||||
{
|
||||
$rocket->setPayload(null);
|
||||
}
|
||||
}
|
40
src/Plugin/Wechat/Fund/Transfer/QueryBatchDetailIdPlugin.php
Normal file
40
src/Plugin/Wechat/Fund/Transfer/QueryBatchDetailIdPlugin.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
|
||||
class QueryBatchDetailIdPlugin extends GeneralPlugin
|
||||
{
|
||||
protected function getMethod(): string
|
||||
{
|
||||
return 'GET';
|
||||
}
|
||||
|
||||
protected function doSomething(Rocket $rocket): void
|
||||
{
|
||||
$rocket->setPayload(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Yansongda\Pay\Exception\InvalidParamsException
|
||||
*/
|
||||
protected function getUri(Rocket $rocket): string
|
||||
{
|
||||
$payload = $rocket->getPayload();
|
||||
|
||||
if (is_null($payload->get('batch_id')) || is_null($payload->get('detail_id'))) {
|
||||
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
|
||||
}
|
||||
|
||||
return 'v3/transfer/batches/batch-id/'.
|
||||
$payload->get('batch_id').
|
||||
'/details/detail-id/'.
|
||||
$payload->get('detail_id');
|
||||
}
|
||||
}
|
38
src/Plugin/Wechat/Fund/Transfer/QueryBatchIdPlugin.php
Normal file
38
src/Plugin/Wechat/Fund/Transfer/QueryBatchIdPlugin.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
|
||||
class QueryBatchIdPlugin extends GeneralPlugin
|
||||
{
|
||||
protected function getMethod(): string
|
||||
{
|
||||
return 'GET';
|
||||
}
|
||||
|
||||
protected function doSomething(Rocket $rocket): void
|
||||
{
|
||||
$rocket->setPayload(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Yansongda\Pay\Exception\InvalidParamsException
|
||||
*/
|
||||
protected function getUri(Rocket $rocket): string
|
||||
{
|
||||
$payload = $rocket->getPayload();
|
||||
|
||||
if (is_null($payload->get('batch_id')) || is_null($payload->get('need_query_detail'))) {
|
||||
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
|
||||
}
|
||||
|
||||
return 'v3/transfer/batches/batch-id/'.$payload->get('batch_id').
|
||||
'?'.$payload->query();
|
||||
}
|
||||
}
|
37
src/Plugin/Wechat/Fund/Transfer/QueryBillReceiptPlugin.php
Normal file
37
src/Plugin/Wechat/Fund/Transfer/QueryBillReceiptPlugin.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
|
||||
class QueryBillReceiptPlugin extends GeneralPlugin
|
||||
{
|
||||
protected function getMethod(): string
|
||||
{
|
||||
return 'GET';
|
||||
}
|
||||
|
||||
protected function doSomething(Rocket $rocket): void
|
||||
{
|
||||
$rocket->setPayload(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Yansongda\Pay\Exception\InvalidParamsException
|
||||
*/
|
||||
protected function getUri(Rocket $rocket): string
|
||||
{
|
||||
$payload = $rocket->getPayload();
|
||||
|
||||
if (is_null($payload->get('out_batch_no'))) {
|
||||
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
|
||||
}
|
||||
|
||||
return 'v3/transfer/bill-receipt/'.$payload->get('out_batch_no');
|
||||
}
|
||||
}
|
37
src/Plugin/Wechat/Fund/Transfer/QueryDetailReceiptPlugin.php
Normal file
37
src/Plugin/Wechat/Fund/Transfer/QueryDetailReceiptPlugin.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
|
||||
class QueryDetailReceiptPlugin extends GeneralPlugin
|
||||
{
|
||||
protected function getMethod(): string
|
||||
{
|
||||
return 'GET';
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Yansongda\Pay\Exception\InvalidParamsException
|
||||
*/
|
||||
protected function doSomething(Rocket $rocket): void
|
||||
{
|
||||
$payload = $rocket->getPayload();
|
||||
|
||||
if (is_null($payload->get('out_detail_no')) || is_null($payload->get('accept_type'))) {
|
||||
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
|
||||
}
|
||||
|
||||
$rocket->setPayload(null);
|
||||
}
|
||||
|
||||
protected function getUri(Rocket $rocket): string
|
||||
{
|
||||
return 'v3/transfer-detail/electronic-receipts?'.$rocket->getPayload()->query();
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
|
||||
class QueryOutBatchDetailNoPlugin extends GeneralPlugin
|
||||
{
|
||||
protected function getMethod(): string
|
||||
{
|
||||
return 'GET';
|
||||
}
|
||||
|
||||
protected function doSomething(Rocket $rocket): void
|
||||
{
|
||||
$rocket->setPayload(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Yansongda\Pay\Exception\InvalidParamsException
|
||||
*/
|
||||
protected function getUri(Rocket $rocket): string
|
||||
{
|
||||
$payload = $rocket->getPayload();
|
||||
|
||||
if (is_null($payload->get('out_batch_no')) || is_null($payload->get('out_detail_no'))) {
|
||||
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
|
||||
}
|
||||
|
||||
return 'v3/transfer/batches/out-batch-no/'.
|
||||
$payload->get('out_batch_no').
|
||||
'/details/out-detail-no/'.
|
||||
$payload->get('out_detail_no');
|
||||
}
|
||||
}
|
38
src/Plugin/Wechat/Fund/Transfer/QueryOutBatchNoPlugin.php
Normal file
38
src/Plugin/Wechat/Fund/Transfer/QueryOutBatchNoPlugin.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
|
||||
class QueryOutBatchNoPlugin extends GeneralPlugin
|
||||
{
|
||||
protected function getMethod(): string
|
||||
{
|
||||
return 'GET';
|
||||
}
|
||||
|
||||
protected function doSomething(Rocket $rocket): void
|
||||
{
|
||||
$rocket->setPayload(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Yansongda\Pay\Exception\InvalidParamsException
|
||||
*/
|
||||
protected function getUri(Rocket $rocket): string
|
||||
{
|
||||
$payload = $rocket->getPayload();
|
||||
|
||||
if (is_null($payload->get('out_batch_no')) || is_null($payload->get('need_query_detail'))) {
|
||||
throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
|
||||
}
|
||||
|
||||
return 'v3/transfer/batches/out-batch-no/'.$payload->get('out_batch_no').
|
||||
'?'.$payload->query();
|
||||
}
|
||||
}
|
@ -58,10 +58,10 @@ abstract class GeneralPlugin implements PluginInterface
|
||||
protected function getUrl(Rocket $rocket): string
|
||||
{
|
||||
$params = $rocket->getParams();
|
||||
$mode = get_wechat_config($params)->get('mode');
|
||||
|
||||
return get_wechat_base_uri($params).
|
||||
(Pay::MODE_SERVICE == $mode ? $this->getPartnerUri($rocket) : $this->getUri($rocket));
|
||||
$url = Pay::MODE_SERVICE == get_wechat_config($params)->get('mode') ? $this->getPartnerUri($rocket) : $this->getUri($rocket);
|
||||
|
||||
return 0 === strpos($url, 'http') ? $url : (get_wechat_base_uri($params).$url);
|
||||
}
|
||||
|
||||
protected function getHeaders(): array
|
||||
|
57
tests/Plugin/Wechat/Fund/Balance/QueryDayEndPluginTest.php
Normal file
57
tests/Plugin/Wechat/Fund/Balance/QueryDayEndPluginTest.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Yansongda\Pay\Tests\Plugin\Wechat\Fund\Balance;
|
||||
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Pay;
|
||||
use Yansongda\Pay\Plugin\Wechat\Fund\Balance\QueryDayEndPlugin;
|
||||
use Yansongda\Pay\Provider\Wechat;
|
||||
use Yansongda\Pay\Rocket;
|
||||
use Yansongda\Pay\Tests\TestCase;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class QueryDayEndPluginTest extends TestCase
|
||||
{
|
||||
public function testNormal()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['account_type' => '123', 'date' => '2021-10-23']));
|
||||
|
||||
$plugin = new QueryDayEndPlugin();
|
||||
|
||||
$result = $plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
|
||||
$radar = $result->getRadar();
|
||||
|
||||
self::assertEquals(new Uri(Wechat::URL[Pay::MODE_NORMAL].'v3/merchant/fund/dayendbalance/123?date=2021-10-23'), $radar->getUri());
|
||||
self::assertEquals('GET', $radar->getMethod());
|
||||
}
|
||||
|
||||
public function testNormalNoAccountType()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['date' => '2021-10-23']));
|
||||
|
||||
$plugin = new QueryDayEndPlugin();
|
||||
|
||||
self::expectException(InvalidParamsException::class);
|
||||
self::expectExceptionCode(Exception::MISSING_NECESSARY_PARAMS);
|
||||
|
||||
$plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
|
||||
public function testNormalNoDate()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['account_type' => '123']));
|
||||
|
||||
$plugin = new QueryDayEndPlugin();
|
||||
|
||||
self::expectException(InvalidParamsException::class);
|
||||
self::expectExceptionCode(Exception::MISSING_NECESSARY_PARAMS);
|
||||
|
||||
$plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
}
|
44
tests/Plugin/Wechat/Fund/Balance/QueryPluginTest.php
Normal file
44
tests/Plugin/Wechat/Fund/Balance/QueryPluginTest.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Yansongda\Pay\Tests\Plugin\Wechat\Fund\Balance;
|
||||
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Pay;
|
||||
use Yansongda\Pay\Plugin\Wechat\Fund\Balance\QueryPlugin;
|
||||
use Yansongda\Pay\Provider\Wechat;
|
||||
use Yansongda\Pay\Rocket;
|
||||
use Yansongda\Pay\Tests\TestCase;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class QueryPluginTest extends TestCase
|
||||
{
|
||||
public function testNormal()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['account_type' => '123']));
|
||||
|
||||
$plugin = new QueryPlugin();
|
||||
|
||||
$result = $plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
|
||||
$radar = $result->getRadar();
|
||||
|
||||
self::assertEquals(new Uri(Wechat::URL[Pay::MODE_NORMAL].'v3/merchant/fund/balance/123'), $radar->getUri());
|
||||
self::assertEquals('GET', $radar->getMethod());
|
||||
}
|
||||
|
||||
public function testNormalNoAccountType()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection());
|
||||
|
||||
$plugin = new QueryPlugin();
|
||||
|
||||
self::expectException(InvalidParamsException::class);
|
||||
self::expectExceptionCode(Exception::MISSING_NECESSARY_PARAMS);
|
||||
|
||||
$plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Yansongda\Pay\Tests\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Pay;
|
||||
use Yansongda\Pay\Plugin\Wechat\Fund\Transfer\CreateBillReceiptPlugin;
|
||||
use Yansongda\Pay\Provider\Wechat;
|
||||
use Yansongda\Pay\Rocket;
|
||||
use Yansongda\Pay\Tests\TestCase;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class CreateBillReceiptPluginTest extends TestCase
|
||||
{
|
||||
public function testNormal()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['out_batch_no' => '123']));
|
||||
|
||||
$plugin = new CreateBillReceiptPlugin();
|
||||
|
||||
$result = $plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
|
||||
$radar = $result->getRadar();
|
||||
$payload = $result->getPayload();
|
||||
|
||||
self::assertEquals(new Uri(Wechat::URL[Pay::MODE_NORMAL].'v3/transfer/bill-receipt'), $radar->getUri());
|
||||
self::assertEquals('123', $payload->get('out_batch_no'));
|
||||
}
|
||||
|
||||
public function testNormalNoOutBatchNo()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection());
|
||||
|
||||
$plugin = new CreateBillReceiptPlugin();
|
||||
|
||||
self::expectException(InvalidParamsException::class);
|
||||
self::expectExceptionCode(Exception::MISSING_NECESSARY_PARAMS);
|
||||
|
||||
$plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Yansongda\Pay\Tests\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Pay;
|
||||
use Yansongda\Pay\Plugin\Wechat\Fund\Transfer\CreateDetailReceiptPlugin;
|
||||
use Yansongda\Pay\Provider\Wechat;
|
||||
use Yansongda\Pay\Rocket;
|
||||
use Yansongda\Pay\Tests\TestCase;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class CreateDetailReceiptPluginTest extends TestCase
|
||||
{
|
||||
public function testNormal()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['out_detail_no' => '123', 'accept_type' => '456']));
|
||||
|
||||
$plugin = new CreateDetailReceiptPlugin();
|
||||
|
||||
$result = $plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
|
||||
$radar = $result->getRadar();
|
||||
$payload = $result->getPayload();
|
||||
|
||||
self::assertEquals(new Uri(Wechat::URL[Pay::MODE_NORMAL].'v3/transfer-detail/electronic-receipts'), $radar->getUri());
|
||||
self::assertEquals('123', $payload->get('out_detail_no'));
|
||||
self::assertEquals('456', $payload->get('accept_type'));
|
||||
}
|
||||
|
||||
public function testNormalNoOutBatchNo()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['accept_type' => '456']));
|
||||
|
||||
$plugin = new CreateDetailReceiptPlugin();
|
||||
|
||||
self::expectException(InvalidParamsException::class);
|
||||
self::expectExceptionCode(Exception::MISSING_NECESSARY_PARAMS);
|
||||
|
||||
$plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
|
||||
public function testNormalNoAcceptType()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['out_detail_no' => '123']));
|
||||
|
||||
$plugin = new CreateDetailReceiptPlugin();
|
||||
|
||||
self::expectException(InvalidParamsException::class);
|
||||
self::expectExceptionCode(Exception::MISSING_NECESSARY_PARAMS);
|
||||
|
||||
$plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
}
|
30
tests/Plugin/Wechat/Fund/Transfer/CreatePluginTest.php
Normal file
30
tests/Plugin/Wechat/Fund/Transfer/CreatePluginTest.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Yansongda\Pay\Tests\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Yansongda\Pay\Pay;
|
||||
use Yansongda\Pay\Plugin\Wechat\Fund\Transfer\CreatePlugin;
|
||||
use Yansongda\Pay\Provider\Wechat;
|
||||
use Yansongda\Pay\Rocket;
|
||||
use Yansongda\Pay\Tests\TestCase;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class CreatePluginTest extends TestCase
|
||||
{
|
||||
public function testNormal()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection());
|
||||
|
||||
$plugin = new CreatePlugin();
|
||||
|
||||
$result = $plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
|
||||
$radar = $result->getRadar();
|
||||
$payload = $result->getPayload();
|
||||
|
||||
self::assertEquals(new Uri(Wechat::URL[Pay::MODE_NORMAL].'v3/transfer/batches'), $radar->getUri());
|
||||
self::assertEquals('wx55955316af4ef13', $payload->get('appid'));
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Yansongda\Pay\Tests\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Plugin\Wechat\Fund\Transfer\DownloadReceiptPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
use Yansongda\Pay\Tests\TestCase;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class DownloadReceiptPluginTest extends TestCase
|
||||
{
|
||||
public function testNormal()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['download_url' => 'https://yansongda.cn']));
|
||||
|
||||
$plugin = new DownloadReceiptPlugin();
|
||||
|
||||
$result = $plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
|
||||
$radar = $result->getRadar();
|
||||
|
||||
self::assertEquals('GET', $radar->getMethod());
|
||||
self::assertEquals(new Uri('https://yansongda.cn'), $radar->getUri());
|
||||
}
|
||||
|
||||
public function testNormalNoDownloadUrl()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection());
|
||||
|
||||
$plugin = new DownloadReceiptPlugin();
|
||||
|
||||
self::expectException(InvalidParamsException::class);
|
||||
self::expectExceptionCode(Exception::MISSING_NECESSARY_PARAMS);
|
||||
|
||||
$plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Yansongda\Pay\Tests\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Pay;
|
||||
use Yansongda\Pay\Plugin\Wechat\Fund\Transfer\QueryBatchDetailIdPlugin;
|
||||
use Yansongda\Pay\Provider\Wechat;
|
||||
use Yansongda\Pay\Rocket;
|
||||
use Yansongda\Pay\Tests\TestCase;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class QueryBatchDetailIdPluginTest extends TestCase
|
||||
{
|
||||
public function testNormal()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['batch_id' => '123', 'detail_id' => '456']));
|
||||
|
||||
$plugin = new QueryBatchDetailIdPlugin();
|
||||
|
||||
$result = $plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
|
||||
$radar = $result->getRadar();
|
||||
|
||||
self::assertEquals(new Uri(Wechat::URL[Pay::MODE_NORMAL].'v3/transfer/batches/batch-id/123/details/detail-id/456'), $radar->getUri());
|
||||
self::assertEquals('GET', $radar->getMethod());
|
||||
}
|
||||
|
||||
public function testNormalNoBatchId()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['detail' => '456']));
|
||||
|
||||
$plugin = new QueryBatchDetailIdPlugin();
|
||||
|
||||
self::expectException(InvalidParamsException::class);
|
||||
self::expectExceptionCode(Exception::MISSING_NECESSARY_PARAMS);
|
||||
|
||||
$plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
|
||||
public function testNormalNoDetailId()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['batch_id' => '123']));
|
||||
|
||||
$plugin = new QueryBatchDetailIdPlugin();
|
||||
|
||||
self::expectException(InvalidParamsException::class);
|
||||
self::expectExceptionCode(Exception::MISSING_NECESSARY_PARAMS);
|
||||
|
||||
$plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
}
|
56
tests/Plugin/Wechat/Fund/Transfer/QueryBatchIdPluginTest.php
Normal file
56
tests/Plugin/Wechat/Fund/Transfer/QueryBatchIdPluginTest.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Yansongda\Pay\Tests\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Plugin\Wechat\Fund\Transfer\QueryBatchIdPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
use Yansongda\Pay\Tests\TestCase;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class QueryBatchIdPluginTest extends TestCase
|
||||
{
|
||||
public function testNormal()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['batch_id' => '123', 'need_query_detail' => false]));
|
||||
|
||||
$plugin = new QueryBatchIdPlugin();
|
||||
|
||||
$result = $plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
|
||||
$radar = $result->getRadar();
|
||||
$url = $radar->getUri();
|
||||
|
||||
self::assertEquals('/v3/transfer/batches/batch-id/123', $url->getPath());
|
||||
self::assertStringContainsString('need_query_detail=0', $url->getQuery());
|
||||
self::assertEquals('GET', $radar->getMethod());
|
||||
}
|
||||
|
||||
public function testNormalNoBatchId()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['need_query_detail' => false]));
|
||||
|
||||
$plugin = new QueryBatchIdPlugin();
|
||||
|
||||
self::expectException(InvalidParamsException::class);
|
||||
self::expectExceptionCode(Exception::MISSING_NECESSARY_PARAMS);
|
||||
|
||||
$plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
|
||||
public function testNormalNoNeedQueryDetail()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['batch_id' => '123']));
|
||||
|
||||
$plugin = new QueryBatchIdPlugin();
|
||||
|
||||
self::expectException(InvalidParamsException::class);
|
||||
self::expectExceptionCode(Exception::MISSING_NECESSARY_PARAMS);
|
||||
|
||||
$plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Yansongda\Pay\Tests\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Pay;
|
||||
use Yansongda\Pay\Plugin\Wechat\Fund\Transfer\QueryBillReceiptPlugin;
|
||||
use Yansongda\Pay\Provider\Wechat;
|
||||
use Yansongda\Pay\Rocket;
|
||||
use Yansongda\Pay\Tests\TestCase;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class QueryBillReceiptPluginTest extends TestCase
|
||||
{
|
||||
public function testNormal()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['out_batch_no' => '123']));
|
||||
|
||||
$plugin = new QueryBillReceiptPlugin();
|
||||
|
||||
$result = $plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
|
||||
$radar = $result->getRadar();
|
||||
|
||||
self::assertEquals(new Uri(Wechat::URL[Pay::MODE_NORMAL].'v3/transfer/bill-receipt/123'), $radar->getUri());
|
||||
self::assertEquals('GET', $radar->getMethod());
|
||||
}
|
||||
|
||||
public function testNormalNoOutBatchNo()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection());
|
||||
|
||||
$plugin = new QueryBillReceiptPlugin();
|
||||
|
||||
self::expectException(InvalidParamsException::class);
|
||||
self::expectExceptionCode(Exception::MISSING_NECESSARY_PARAMS);
|
||||
|
||||
$plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Yansongda\Pay\Tests\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Plugin\Wechat\Fund\Transfer\QueryDetailReceiptPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
use Yansongda\Pay\Tests\TestCase;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class QueryDetailReceiptPluginTest extends TestCase
|
||||
{
|
||||
public function testNormal()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['out_detail_no' => '123', 'accept_type' => '456']));
|
||||
|
||||
$plugin = new QueryDetailReceiptPlugin();
|
||||
|
||||
$result = $plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
|
||||
$radar = $result->getRadar();
|
||||
$url = $radar->getUri();
|
||||
|
||||
self::assertEquals('/v3/transfer-detail/electronic-receipts', $url->getPath());
|
||||
self::assertStringContainsString('out_detail_no=123', $url->getQuery());
|
||||
self::assertStringContainsString('accept_type=456', $url->getQuery());
|
||||
self::assertEquals('GET', $radar->getMethod());
|
||||
}
|
||||
|
||||
public function testNormalNoOutDetailNo()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['accept_type' => '456']));
|
||||
|
||||
$plugin = new QueryDetailReceiptPlugin();
|
||||
|
||||
self::expectException(InvalidParamsException::class);
|
||||
self::expectExceptionCode(Exception::MISSING_NECESSARY_PARAMS);
|
||||
|
||||
$plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
|
||||
public function testNormalNoAcceptType()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['out_detail_no' => '123']));
|
||||
|
||||
$plugin = new QueryDetailReceiptPlugin();
|
||||
|
||||
self::expectException(InvalidParamsException::class);
|
||||
self::expectExceptionCode(Exception::MISSING_NECESSARY_PARAMS);
|
||||
|
||||
$plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Yansongda\Pay\Tests\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Pay;
|
||||
use Yansongda\Pay\Plugin\Wechat\Fund\Transfer\QueryOutBatchDetailNoPlugin;
|
||||
use Yansongda\Pay\Provider\Wechat;
|
||||
use Yansongda\Pay\Rocket;
|
||||
use Yansongda\Pay\Tests\TestCase;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class QueryOutBatchDetailNoPluginTest extends TestCase
|
||||
{
|
||||
public function testNormal()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['out_batch_no' => '123', 'out_detail_no' => '456']));
|
||||
|
||||
$plugin = new QueryOutBatchDetailNoPlugin();
|
||||
|
||||
$result = $plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
|
||||
$radar = $result->getRadar();
|
||||
|
||||
self::assertEquals(new Uri(Wechat::URL[Pay::MODE_NORMAL].'v3/transfer/batches/out-batch-no/123/details/out-detail-no/456'), $radar->getUri());
|
||||
self::assertEquals('GET', $radar->getMethod());
|
||||
}
|
||||
|
||||
public function testNormalNoBatchId()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['out_detail_no' => '456']));
|
||||
|
||||
$plugin = new QueryOutBatchDetailNoPlugin();
|
||||
|
||||
self::expectException(InvalidParamsException::class);
|
||||
self::expectExceptionCode(Exception::MISSING_NECESSARY_PARAMS);
|
||||
|
||||
$plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
|
||||
public function testNormalNoDetailId()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['out_batch_no' => '123']));
|
||||
|
||||
$plugin = new QueryOutBatchDetailNoPlugin();
|
||||
|
||||
self::expectException(InvalidParamsException::class);
|
||||
self::expectExceptionCode(Exception::MISSING_NECESSARY_PARAMS);
|
||||
|
||||
$plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Yansongda\Pay\Tests\Plugin\Wechat\Fund\Transfer;
|
||||
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidParamsException;
|
||||
use Yansongda\Pay\Plugin\Wechat\Fund\Transfer\QueryOutBatchNoPlugin;
|
||||
use Yansongda\Pay\Rocket;
|
||||
use Yansongda\Pay\Tests\TestCase;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class QueryOutBatchNoPluginTest extends TestCase
|
||||
{
|
||||
public function testNormal()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['out_batch_no' => '123', 'need_query_detail' => false]));
|
||||
|
||||
$plugin = new QueryOutBatchNoPlugin();
|
||||
|
||||
$result = $plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
|
||||
$radar = $result->getRadar();
|
||||
$url = $radar->getUri();
|
||||
|
||||
self::assertEquals('/v3/transfer/batches/out-batch-no/123', $url->getPath());
|
||||
self::assertStringContainsString('need_query_detail=0', $url->getQuery());
|
||||
self::assertEquals('GET', $radar->getMethod());
|
||||
}
|
||||
|
||||
public function testNormalNoOutBatchNo()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['need_query_detail' => false]));
|
||||
|
||||
$plugin = new QueryOutBatchNoPlugin();
|
||||
|
||||
self::expectException(InvalidParamsException::class);
|
||||
self::expectExceptionCode(Exception::MISSING_NECESSARY_PARAMS);
|
||||
|
||||
$plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
|
||||
public function testNormalNoNeedQueryDetail()
|
||||
{
|
||||
$rocket = new Rocket();
|
||||
$rocket->setParams([])->setPayload(new Collection(['out_batch_no' => '123']));
|
||||
|
||||
$plugin = new QueryOutBatchNoPlugin();
|
||||
|
||||
self::expectException(InvalidParamsException::class);
|
||||
self::expectExceptionCode(Exception::MISSING_NECESSARY_PARAMS);
|
||||
|
||||
$plugin->assembly($rocket, function ($rocket) { return $rocket; });
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user