Skip to content

Commit

Permalink
fix: 微信 v2 版响应 packer 错误 (#758)
Browse files Browse the repository at this point in the history
  • Loading branch information
yansongda authored Mar 20, 2023
1 parent 2d21acc commit 5b211bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Plugin/Wechat/GeneralV2Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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] ?? '',
Expand Down
2 changes: 2 additions & 0 deletions tests/Plugin/Wechat/GeneralV2PluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 5b211bd

Please sign in to comment.