fix: 微信投诉相关插件响应解析错误 (#746)

* fix: 微信投诉相关插件响应解析错误

* changelog

* style: fix coding style
This commit is contained in:
yansongda 2023-02-26 19:52:56 +08:00 committed by GitHub
parent 765085bdd1
commit 81df62a863
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 0 deletions

View File

@ -1,3 +1,9 @@
## v3.2.14
### fixed
- fix: 微信投诉相关插件响应解析错误(#746)
## v3.2.13
### optimized

View File

@ -9,6 +9,7 @@ use Yansongda\Pay\Exception\InvalidParamsException;
use function Yansongda\Pay\get_wechat_config;
use Yansongda\Pay\Parser\OriginResponseParser;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
use Yansongda\Supports\Collection;
@ -24,6 +25,8 @@ class CompleteComplaintPlugin extends GeneralPlugin
*/
protected function doSomething(Rocket $rocket): void
{
$rocket->setDirection(OriginResponseParser::class);
$payload = $rocket->getPayload();
$config = get_wechat_config($rocket->getParams());

View File

@ -9,6 +9,7 @@ use Yansongda\Pay\Exception\InvalidParamsException;
use function Yansongda\Pay\get_wechat_config;
use Yansongda\Pay\Parser\OriginResponseParser;
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
use Yansongda\Pay\Rocket;
@ -23,6 +24,8 @@ class ResponseComplaintPlugin extends GeneralPlugin
*/
protected function doSomething(Rocket $rocket): void
{
$rocket->setDirection(OriginResponseParser::class);
$config = get_wechat_config($rocket->getParams());
$payload = $rocket->getPayload();

View File

@ -5,6 +5,7 @@ namespace Yansongda\Pay\Tests\Plugin\Wechat\Risk\Complaints;
use GuzzleHttp\Psr7\Uri;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Parser\OriginResponseParser;
use Yansongda\Pay\Pay;
use Yansongda\Pay\Plugin\Wechat\Risk\Complaints\CompleteComplaintPlugin;
use Yansongda\Pay\Provider\Wechat;
@ -38,6 +39,7 @@ class CompleteComplaintPluginTest extends TestCase
self::assertEquals(new Uri(Wechat::URL[Pay::MODE_NORMAL].'v3/merchant-service/complaints-v2/123/complete'), $radar->getUri());
self::assertEquals(['complainted_mchid' => '1600314069'], $rocket->getPayload()->toArray());
self::assertEquals('POST', $radar->getMethod());
self::assertEquals(OriginResponseParser::class, $result->getDirection());
}
public function testDirectMchId()
@ -51,6 +53,7 @@ class CompleteComplaintPluginTest extends TestCase
self::assertEquals(new Uri(Wechat::URL[Pay::MODE_NORMAL].'v3/merchant-service/complaints-v2/456/complete'), $radar->getUri());
self::assertEquals(['complainted_mchid' => 'bar'], $rocket->getPayload()->toArray());
self::assertEquals(OriginResponseParser::class, $result->getDirection());
}
public function testMissingId()

View File

@ -5,6 +5,7 @@ namespace Yansongda\Pay\Tests\Plugin\Wechat\Risk\Complaints;
use GuzzleHttp\Psr7\Uri;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Parser\OriginResponseParser;
use Yansongda\Pay\Pay;
use Yansongda\Pay\Plugin\Wechat\Risk\Complaints\ResponseComplaintPlugin;
use Yansongda\Pay\Provider\Wechat;
@ -35,6 +36,7 @@ class ResponseComplaintPluginTest extends TestCase
$radar = $result->getRadar();
self::assertEquals(OriginResponseParser::class, $result->getDirection());
self::assertEquals(new Uri(Wechat::URL[Pay::MODE_NORMAL].'v3/merchant-service/complaints-v2/123/response'), $radar->getUri());
self::assertEquals('POST', $radar->getMethod());
self::assertEquals(['foo' => 'bar', 'complainted_mchid' => '1600314069'], $rocket->getPayload()->toArray());
@ -49,6 +51,7 @@ class ResponseComplaintPluginTest extends TestCase
$radar = $result->getRadar();
self::assertEquals(OriginResponseParser::class, $result->getDirection());
self::assertEquals(new Uri(Wechat::URL[Pay::MODE_NORMAL].'v3/merchant-service/complaints-v2/456/response'), $radar->getUri());
self::assertEquals(['complainted_mchid' => 'bar', 'u' => 'a'], $rocket->getPayload()->toArray());
}