From 79ecf0ce68900d891e9fd74380b7d2c8be5f4322 Mon Sep 17 00:00:00 2001 From: yansongda Date: Mon, 20 Mar 2023 10:19:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BE=AE=E4=BF=A1=20v2=20=E7=89=88?= =?UTF-8?q?=E5=93=8D=E5=BA=94=20packer=20=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Plugin/Wechat/GeneralV2Plugin.php | 3 ++- tests/Plugin/Wechat/GeneralV2PluginTest.php | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Plugin/Wechat/GeneralV2Plugin.php b/src/Plugin/Wechat/GeneralV2Plugin.php index f9f3dd004..e4685499e 100644 --- a/src/Plugin/Wechat/GeneralV2Plugin.php +++ b/src/Plugin/Wechat/GeneralV2Plugin.php @@ -6,6 +6,7 @@ use function Yansongda\Pay\get_wechat_config; +use Yansongda\Pay\Packer\XmlPacker; use Yansongda\Pay\Rocket; abstract class GeneralV2Plugin extends GeneralPlugin @@ -27,7 +28,7 @@ protected function doSomething(Rocket $rocket): void $config = get_wechat_config($rocket->getParams()); $configKey = $this->getConfigKey($rocket->getParams()); - $rocket->mergeParams(['_version' => 'v2']); + $rocket->setPacker(XmlPacker::class)->mergeParams(['_version' => 'v2']); $rocket->mergePayload([ 'appid' => $config[$configKey] ?? '', diff --git a/tests/Plugin/Wechat/GeneralV2PluginTest.php b/tests/Plugin/Wechat/GeneralV2PluginTest.php index 1345a651d..14bac8949 100644 --- a/tests/Plugin/Wechat/GeneralV2PluginTest.php +++ b/tests/Plugin/Wechat/GeneralV2PluginTest.php @@ -4,6 +4,7 @@ use GuzzleHttp\Psr7\Uri; use Psr\Http\Message\RequestInterface; +use Yansongda\Pay\Packer\XmlPacker; use Yansongda\Pay\Pay; use Yansongda\Pay\Provider\Wechat; use Yansongda\Pay\Rocket; @@ -32,6 +33,7 @@ public function testNormal() $params = $result->getParams(); $payload = $result->getPayload(); + self::assertEquals(XmlPacker::class, $result->getPacker()); self::assertInstanceOf(RequestInterface::class, $radar); self::assertEquals('POST', $radar->getMethod()); self::assertEquals(new Uri(Wechat::URL[Pay::MODE_NORMAL].'yansongda/pay'), $radar->getUri());