From df27f9538d769db5fd3f158c631f5835b6a94731 Mon Sep 17 00:00:00 2001 From: yansongda Date: Thu, 4 Nov 2021 14:32:24 +0800 Subject: [PATCH] =?UTF-8?q?fixed:=20=E4=B8=8B=E8=BD=BD=E5=AF=B9=E8=B4=A6?= =?UTF-8?q?=E5=8D=95=E6=97=B6=E5=93=8D=E5=BA=94=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 12 +++++ .../Fund/Transfer/DownloadReceiptPlugin.php | 3 ++ .../Wechat/Pay/Common/DownloadBillPlugin.php | 3 ++ .../Transfer/DownloadReceiptPluginTest.php | 2 + .../Pay/Common/DownloadBillPluginTest.php | 44 +++++++++++++++++++ 5 files changed, 64 insertions(+) create mode 100644 tests/Plugin/Wechat/Pay/Common/DownloadBillPluginTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e9b792..fe048ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## v3.0.15 + +### fixed + +- fixed: 下载对账单时响应解析 (#511) + +## v3.0.14 + +### fixed + +- fixed: app 支付调起签名中参数大小写问题 (#7916fdd) + ## v3.0.13 ### fixed diff --git a/src/Plugin/Wechat/Fund/Transfer/DownloadReceiptPlugin.php b/src/Plugin/Wechat/Fund/Transfer/DownloadReceiptPlugin.php index 9cc9f6b..2295a3c 100644 --- a/src/Plugin/Wechat/Fund/Transfer/DownloadReceiptPlugin.php +++ b/src/Plugin/Wechat/Fund/Transfer/DownloadReceiptPlugin.php @@ -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); } } diff --git a/src/Plugin/Wechat/Pay/Common/DownloadBillPlugin.php b/src/Plugin/Wechat/Pay/Common/DownloadBillPlugin.php index 1cc39c7..d9746a5 100644 --- a/src/Plugin/Wechat/Pay/Common/DownloadBillPlugin.php +++ b/src/Plugin/Wechat/Pay/Common/DownloadBillPlugin.php @@ -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); } } diff --git a/tests/Plugin/Wechat/Fund/Transfer/DownloadReceiptPluginTest.php b/tests/Plugin/Wechat/Fund/Transfer/DownloadReceiptPluginTest.php index fd9660d..33e4382 100644 --- a/tests/Plugin/Wechat/Fund/Transfer/DownloadReceiptPluginTest.php +++ b/tests/Plugin/Wechat/Fund/Transfer/DownloadReceiptPluginTest.php @@ -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()); } diff --git a/tests/Plugin/Wechat/Pay/Common/DownloadBillPluginTest.php b/tests/Plugin/Wechat/Pay/Common/DownloadBillPluginTest.php new file mode 100644 index 0000000..c8b6ef3 --- /dev/null +++ b/tests/Plugin/Wechat/Pay/Common/DownloadBillPluginTest.php @@ -0,0 +1,44 @@ +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; }); + } +}