diff --git a/src/Functions.php b/src/Functions.php index 429a223..92780e0 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -13,7 +13,8 @@ use Yansongda\Supports\Str; if (!function_exists('should_http_request')) { function should_http_request(Rocket $rocket): bool { - return !in_array(NoHttpRequestParser::class, class_parents($rocket->getDirection())); + return NoHttpRequestParser::class !== $rocket->getDirection() && + !in_array(NoHttpRequestParser::class, class_parents($rocket->getDirection())); } } diff --git a/src/Plugin/Alipay/CallbackPlugin.php b/src/Plugin/Alipay/CallbackPlugin.php index 13a0450..0b5a8c4 100644 --- a/src/Plugin/Alipay/CallbackPlugin.php +++ b/src/Plugin/Alipay/CallbackPlugin.php @@ -7,6 +7,7 @@ namespace Yansongda\Pay\Plugin\Alipay; use Closure; use Yansongda\Pay\Contract\PluginInterface; use Yansongda\Pay\Exception\InvalidResponseException; +use Yansongda\Pay\Parser\NoHttpRequestParser; use Yansongda\Pay\Rocket; use Yansongda\Supports\Collection; @@ -23,7 +24,7 @@ class CallbackPlugin implements PluginInterface { $this->filterPayload($rocket); - if ($rocket->getParams()['sign'] ?? false) { + if (!($rocket->getParams()['sign'] ?? false)) { throw new InvalidResponseException(InvalidResponseException::INVALID_RESPONSE_SIGN, '', $rocket->getParams()); } @@ -35,6 +36,9 @@ class CallbackPlugin implements PluginInterface throw new InvalidResponseException(InvalidResponseException::INVALID_RESPONSE_SIGN, '', $rocket->getParams()); } + $rocket->setDirection(NoHttpRequestParser::class) + ->setDestination($rocket->getPayload()); + return $next($rocket); } diff --git a/src/Provider/Alipay.php b/src/Provider/Alipay.php index 8662979..0ea9ba5 100644 --- a/src/Provider/Alipay.php +++ b/src/Provider/Alipay.php @@ -121,7 +121,7 @@ class Alipay extends AbstractProvider $response = $this->getCallbackParams($contents); return $this->pay( - [CallbackPlugin::class], array_merge($response, $config ?? []) + [CallbackPlugin::class], $response->merge($config)->all() ); }