mirror of
https://gitee.com/yansongda/pay.git
synced 2024-11-29 18:58:38 +08:00
optimize: 优化微信 ResponsePlugin
插件去除不必要的返回参数 (#996)
This commit is contained in:
parent
66942f1db7
commit
3683c69c1a
@ -1,5 +1,9 @@
|
||||
## TBD - v3.7.5
|
||||
|
||||
### optimized
|
||||
|
||||
- optimize: 优化微信 `ResponsePlugin` 插件去除不必要的返回参数(#996)
|
||||
|
||||
### deprecated
|
||||
|
||||
- deprecate: 微信 `StartPlugin` 改为使用 `yansongda/artful` 中的插件(#993)
|
||||
|
@ -5,14 +5,12 @@ declare(strict_types=1);
|
||||
namespace Yansongda\Pay\Plugin\Wechat;
|
||||
|
||||
use Closure;
|
||||
use Psr\Http\Message\MessageInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Yansongda\Artful\Contract\PluginInterface;
|
||||
use Yansongda\Artful\Exception\InvalidResponseException;
|
||||
use Yansongda\Artful\Logger;
|
||||
use Yansongda\Artful\Rocket;
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class ResponsePlugin implements PluginInterface
|
||||
{
|
||||
@ -26,7 +24,7 @@ class ResponsePlugin implements PluginInterface
|
||||
|
||||
Logger::debug('[Wechat][ResponsePlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$rocket->setDestination($this->validateResponse($rocket));
|
||||
$this->validateResponse($rocket);
|
||||
|
||||
Logger::info('[Wechat][ResponsePlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
@ -36,7 +34,7 @@ class ResponsePlugin implements PluginInterface
|
||||
/**
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
protected function validateResponse(Rocket $rocket): null|Collection|MessageInterface
|
||||
protected function validateResponse(Rocket $rocket): void
|
||||
{
|
||||
$response = $rocket->getDestinationOrigin();
|
||||
|
||||
@ -44,7 +42,5 @@ class ResponsePlugin implements PluginInterface
|
||||
&& ($response->getStatusCode() < 200 || $response->getStatusCode() >= 300)) {
|
||||
throw new InvalidResponseException(Exception::RESPONSE_CODE_WRONG, '微信返回状态码异常,请检查参数是否错误', $rocket->getDestination());
|
||||
}
|
||||
|
||||
return $rocket->getDestination();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user