This commit is contained in:
yansongda 2021-06-17 09:48:38 +08:00
parent f78d464342
commit 737b226daa
2 changed files with 13 additions and 3 deletions

View File

@ -30,7 +30,7 @@ abstract class AbstractProvider implements ProviderInterface
* *
* @return \Yansongda\Supports\Collection|\Psr\Http\Message\ResponseInterface * @return \Yansongda\Supports\Collection|\Psr\Http\Message\ResponseInterface
*/ */
public function call(string $plugin, array $params) public function call(string $plugin, array $params = [])
{ {
if (!class_exists($plugin) || !in_array(ShortcutInterface::class, class_implements($plugin))) { if (!class_exists($plugin) || !in_array(ShortcutInterface::class, class_implements($plugin))) {
throw new InvalidParamsException(InvalidParamsException::SHORTCUT_NOT_FOUND, "[$plugin] is not incompatible"); throw new InvalidParamsException(InvalidParamsException::SHORTCUT_NOT_FOUND, "[$plugin] is not incompatible");
@ -42,8 +42,7 @@ abstract class AbstractProvider implements ProviderInterface
$money = Pay::get($plugin); $money = Pay::get($plugin);
return $this->pay( return $this->pay(
$this->mergeCommonPlugins($money->getPlugins(...$params)), $this->mergeCommonPlugins($money->getPlugins($params)), $params
...$params
); );
} }

View File

@ -110,28 +110,39 @@ class FooProviderStub extends AbstractProvider
{ {
public function find($order): Collection public function find($order): Collection
{ {
return new Collection();
} }
public function cancel($order): Collection public function cancel($order): Collection
{ {
return new Collection();
} }
public function close($order): Collection public function close($order): Collection
{ {
return new Collection();
} }
public function refund(array $order): Collection public function refund(array $order): Collection
{ {
return new Collection();
} }
public function verify($contents = null, ?array $params = null): Collection public function verify($contents = null, ?array $params = null): Collection
{ {
return new Collection();
} }
public function success(): ResponseInterface public function success(): ResponseInterface
{ {
} }
public function mergeCommonPlugins(array $plugins): array
{
return [];
}
} }
class FooPlugin implements PluginInterface class FooPlugin implements PluginInterface
{ {
public function assembly(Rocket $rocket, Closure $next): Rocket public function assembly(Rocket $rocket, Closure $next): Rocket