fixed: 下载对账单时响应解析

This commit is contained in:
yansongda 2021-11-04 14:32:24 +08:00
parent 7916fdd74b
commit df27f9538d
5 changed files with 64 additions and 0 deletions

View File

@ -1,3 +1,15 @@
## v3.0.15
### fixed
- fixed: 下载对账单时响应解析 (#511)
## v3.0.14
### fixed
- fixed: app 支付调起签名中参数大小写问题 (#7916fdd)
## v3.0.13
### fixed

View File

@ -6,6 +6,7 @@ namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Parser\OriginResponseParser;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
@ -32,6 +33,8 @@ class DownloadReceiptPlugin extends GeneralPlugin
protected function doSomething(Rocket $rocket): void
{
$rocket->setDirection(OriginResponseParser::class);
$rocket->setPayload(null);
}
}

View File

@ -6,6 +6,7 @@ namespace Yansongda\Pay\Plugin\Wechat\Pay\Common;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Parser\OriginResponseParser;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
@ -32,6 +33,8 @@ class DownloadBillPlugin extends GeneralPlugin
protected function doSomething(Rocket $rocket): void
{
$rocket->setDirection(OriginResponseParser::class);
$rocket->setPayload(null);
}
}

View File

@ -5,6 +5,7 @@ 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\Parser\OriginResponseParser;
use Yansongda\Pay\Plugin\Wechat\Fund\Transfer\DownloadReceiptPlugin;
use Yansongda\Pay\Rocket;
use Yansongda\Pay\Tests\TestCase;
@ -23,6 +24,7 @@ class DownloadReceiptPluginTest extends TestCase
$radar = $result->getRadar();
self::assertEquals(OriginResponseParser::class, $result->getDirection());
self::assertEquals('GET', $radar->getMethod());
self::assertEquals(new Uri('https://yansongda.cn'), $radar->getUri());
}

View File

@ -0,0 +1,44 @@
<?php
namespace Yansongda\Pay\Tests\Plugin\Wechat\Pay\Common;
use GuzzleHttp\Psr7\Uri;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Parser\OriginResponseParser;
use Yansongda\Pay\Plugin\Wechat\Pay\Common\DownloadBillPlugin;
use Yansongda\Pay\Rocket;
use Yansongda\Pay\Tests\TestCase;
use Yansongda\Supports\Collection;
class DownloadBillPluginTest extends TestCase
{
public function testNormal()
{
$rocket = new Rocket();
$rocket->setParams([])->setPayload(new Collection(['download_url' => 'https://yansongda.cn']));
$plugin = new DownloadBillPlugin();
$result = $plugin->assembly($rocket, function ($rocket) { return $rocket; });
$radar = $result->getRadar();
self::assertEquals(OriginResponseParser::class, $result->getDirection());
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 DownloadBillPlugin();
self::expectException(InvalidParamsException::class);
self::expectExceptionCode(Exception::MISSING_NECESSARY_PARAMS);
$plugin->assembly($rocket, function ($rocket) { return $rocket; });
}
}