chore: 新增epay和cos插件相关类库及配置文件
- 新增epay v2、v3、v3new版本的支付类库及证书文件 - 新增cos云存储类库文件 - 调整文件上传保存格式为按分类存储 - 修复会员、规则、类目等语言翻译键名 - 新增小程序图标等静态资源文件
这个提交包含在:
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Plugin;
|
||||
|
||||
use Closure;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Yansongda\Pay\Contract\DirectionInterface;
|
||||
use Yansongda\Pay\Contract\PackerInterface;
|
||||
use Yansongda\Pay\Contract\PluginInterface;
|
||||
use Yansongda\Pay\Exception\ContainerException;
|
||||
use Yansongda\Pay\Exception\Exception;
|
||||
use Yansongda\Pay\Exception\InvalidConfigException;
|
||||
use Yansongda\Pay\Exception\ServiceNotFoundException;
|
||||
use Yansongda\Pay\Pay;
|
||||
use Yansongda\Pay\Rocket;
|
||||
|
||||
class ParserPlugin implements PluginInterface
|
||||
{
|
||||
/**
|
||||
* @throws ServiceNotFoundException
|
||||
* @throws ContainerException
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
/* @var Rocket $rocket */
|
||||
$rocket = $next($rocket);
|
||||
|
||||
/* @var ResponseInterface $response */
|
||||
$response = $rocket->getDestination();
|
||||
|
||||
return $rocket->setDestination(
|
||||
$this->getDirection($rocket)->parse($this->getPacker($rocket), $response)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ContainerException
|
||||
* @throws InvalidConfigException
|
||||
* @throws ServiceNotFoundException
|
||||
*/
|
||||
protected function getDirection(Rocket $rocket): DirectionInterface
|
||||
{
|
||||
$packer = Pay::get($rocket->getDirection());
|
||||
|
||||
$packer = is_string($packer) ? Pay::get($packer) : $packer;
|
||||
|
||||
if (!$packer instanceof DirectionInterface) {
|
||||
throw new InvalidConfigException(Exception::INVALID_PARSER);
|
||||
}
|
||||
|
||||
return $packer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ContainerException
|
||||
* @throws InvalidConfigException
|
||||
* @throws ServiceNotFoundException
|
||||
*/
|
||||
protected function getPacker(Rocket $rocket): PackerInterface
|
||||
{
|
||||
$packer = Pay::get($rocket->getPacker());
|
||||
|
||||
$packer = is_string($packer) ? Pay::get($packer) : $packer;
|
||||
|
||||
if (!$packer instanceof PackerInterface) {
|
||||
throw new InvalidConfigException(Exception::INVALID_PACKER);
|
||||
}
|
||||
|
||||
return $packer;
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户