mirror of
https://gitee.com/yansongda/pay.git
synced 2024-11-29 10:47:57 +08:00
update
This commit is contained in:
parent
7085de0d74
commit
90f99d2074
@ -4,3 +4,10 @@ filter:
|
||||
|
||||
checks:
|
||||
php: true
|
||||
|
||||
build:
|
||||
nodes:
|
||||
analysis:
|
||||
tests:
|
||||
override:
|
||||
- php-scrutinizer-run
|
||||
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace Yansongda\Pay\Listener;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Yansongda\Pay\Contract\LoggerInterface;
|
||||
use Yansongda\Pay\Event\ApiRequested;
|
||||
use Yansongda\Pay\Event\ApiRequesting;
|
||||
use Yansongda\Pay\Event\MethodCalled;
|
||||
@ -13,29 +12,10 @@ use Yansongda\Pay\Event\PayStarted;
|
||||
use Yansongda\Pay\Event\PayStarting;
|
||||
use Yansongda\Pay\Event\RequestReceived;
|
||||
use Yansongda\Pay\Event\SignFailed;
|
||||
use Yansongda\Pay\Pay;
|
||||
use Yansongda\Pay\Logger;
|
||||
|
||||
class KernelLogSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* @var \Psr\Log\LoggerInterface
|
||||
*/
|
||||
protected $logger;
|
||||
|
||||
/**
|
||||
* Bootstrap.
|
||||
*
|
||||
* @author yansongda <me@yansongda.cn>
|
||||
*
|
||||
* @throws \Yansongda\Pay\Exception\ContainerDependencyException
|
||||
* @throws \Yansongda\Pay\Exception\ContainerException
|
||||
* @throws \Yansongda\Pay\Exception\ServiceNotFoundException
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->logger = Pay::get(LoggerInterface::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of event names this subscriber wants to listen to.
|
||||
*
|
||||
@ -74,7 +54,7 @@ class KernelLogSubscriber implements EventSubscriberInterface
|
||||
*/
|
||||
public function writePayStartingLog(PayStarting $event)
|
||||
{
|
||||
$this->logger->debug("Starting To $event->driver", [$event->gateway, $event->params]);
|
||||
Logger::debug("Starting To $event->driver", [$event->gateway, $event->params]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,7 +64,7 @@ class KernelLogSubscriber implements EventSubscriberInterface
|
||||
*/
|
||||
public function writePayStartedLog(PayStarted $event)
|
||||
{
|
||||
$this->logger->info(
|
||||
Logger::info(
|
||||
"$event->driver $event->gateway Has Started",
|
||||
[$event->endpoint, $event->payload]
|
||||
);
|
||||
@ -97,7 +77,7 @@ class KernelLogSubscriber implements EventSubscriberInterface
|
||||
*/
|
||||
public function writeApiRequestingLog(ApiRequesting $event)
|
||||
{
|
||||
$this->logger->debug("Requesting To $event->driver Api", [$event->endpoint, $event->payload]);
|
||||
Logger::debug("Requesting To $event->driver Api", [$event->endpoint, $event->payload]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,7 +87,7 @@ class KernelLogSubscriber implements EventSubscriberInterface
|
||||
*/
|
||||
public function writeApiRequestedLog(ApiRequested $event)
|
||||
{
|
||||
$this->logger->debug("Result Of $event->driver Api", $event->result);
|
||||
Logger::debug("Result Of $event->driver Api", $event->result);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,7 +97,7 @@ class KernelLogSubscriber implements EventSubscriberInterface
|
||||
*/
|
||||
public function writeSignFailedLog(SignFailed $event)
|
||||
{
|
||||
$this->logger->warning("$event->driver Sign Verify FAILED", $event->data);
|
||||
Logger::warning("$event->driver Sign Verify FAILED", $event->data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -127,7 +107,7 @@ class KernelLogSubscriber implements EventSubscriberInterface
|
||||
*/
|
||||
public function writeRequestReceivedLog(RequestReceived $event)
|
||||
{
|
||||
$this->logger->info("Received $event->driver Request", $event->data);
|
||||
Logger::info("Received $event->driver Request", $event->data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -137,6 +117,6 @@ class KernelLogSubscriber implements EventSubscriberInterface
|
||||
*/
|
||||
public function writeMethodCalledLog(MethodCalled $event)
|
||||
{
|
||||
$this->logger->info("$event->driver $event->gateway Method Has Called", [$event->endpoint, $event->payload]);
|
||||
Logger::info("$event->driver $event->gateway Method Has Called", [$event->endpoint, $event->payload]);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay;
|
||||
|
||||
use Throwable;
|
||||
use Yansongda\Pay\Contract\LoggerInterface;
|
||||
|
||||
/**
|
||||
@ -19,14 +20,13 @@ use Yansongda\Pay\Contract\LoggerInterface;
|
||||
*/
|
||||
class Logger
|
||||
{
|
||||
/**
|
||||
* @throws \Yansongda\Pay\Exception\ContainerDependencyException
|
||||
* @throws \Yansongda\Pay\Exception\ContainerException
|
||||
* @throws \Yansongda\Pay\Exception\ServiceNotFoundException
|
||||
*/
|
||||
public static function __callStatic(string $method, array $args)
|
||||
public static function __callStatic(string $method, array $args): void
|
||||
{
|
||||
$class = Pay::get(LoggerInterface::class);
|
||||
try {
|
||||
$class = Pay::get(LoggerInterface::class);
|
||||
} catch (Throwable $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
forward_static_call_array([$class, $method], $args);
|
||||
}
|
||||
|
@ -5,22 +5,24 @@ declare(strict_types=1);
|
||||
namespace Yansongda\Pay\Plugin\Alipay\Fund;
|
||||
|
||||
use Closure;
|
||||
use Yansongda\Supports\Collection;
|
||||
use Yansongda\Pay\Contract\PluginInterface;
|
||||
use Yansongda\Pay\Rocket;
|
||||
|
||||
class TransUniTransferPlugin
|
||||
class TransUniTransferPlugin implements PluginInterface
|
||||
{
|
||||
public function apply(array $params, Collection $payload, Closure $next): Collection
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
$payload = $payload->merge([
|
||||
$rocket->mergePayload([
|
||||
'method' => 'alipay.fund.trans.uni.transfer',
|
||||
'biz_content' => json_encode(array_merge(
|
||||
'biz_content' => array_merge(
|
||||
[
|
||||
'biz_scene' => 'DIRECT_TRANSFER',
|
||||
'product_code' => 'TRANS_ACCOUNT_NO_PWD',
|
||||
],
|
||||
$params
|
||||
)),
|
||||
$rocket->getParams(),
|
||||
),
|
||||
]);
|
||||
|
||||
return $next($params, $payload);
|
||||
return $next($rocket);
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Alipay\Shortcut;
|
||||
|
||||
use Closure;
|
||||
use Yansongda\Pay\Plugin\Alipay\Fund\TransUniTransferPlugin;
|
||||
use Yansongda\Supports\Collection;
|
||||
|
||||
class TransferPlugin extends TransUniTransferPlugin
|
||||
{
|
||||
public function apply(array $params, Collection $payload, Closure $next): Collection
|
||||
{
|
||||
return parent::apply(...func_get_args());
|
||||
}
|
||||
}
|
18
src/Plugin/Alipay/Shortcut/TransferShortcut.php
Normal file
18
src/Plugin/Alipay/Shortcut/TransferShortcut.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin\Alipay\Shortcut;
|
||||
|
||||
use Yansongda\Pay\Contract\ShortcutInterface;
|
||||
use Yansongda\Pay\Plugin\Alipay\Fund\TransUniTransferPlugin;
|
||||
|
||||
class TransferShortcut implements ShortcutInterface
|
||||
{
|
||||
public function getPlugins(): array
|
||||
{
|
||||
return [
|
||||
TransUniTransferPlugin::class,
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user