PayPlugin   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A assembly() 0 15 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay\Plugin\Alipay\V2\Pay\H5;
6
7
use Closure;
8
use Yansongda\Artful\Contract\PluginInterface;
9
use Yansongda\Artful\Direction\ResponseDirection;
10
use Yansongda\Artful\Exception\ContainerException;
11
use Yansongda\Artful\Exception\ServiceNotFoundException;
12
use Yansongda\Artful\Logger;
13
use Yansongda\Artful\Rocket;
14
use Yansongda\Pay\Traits\SupportServiceProviderTrait;
15
16
/**
17
 * @see https://opendocs.alipay.com/open/29ae8cb6_alipay.trade.wap.pay?pathHash=0a6313c7&ref=api&scene=21
18
 */
19
class PayPlugin implements PluginInterface
20
{
21
    use SupportServiceProviderTrait;
22
23
    /**
24
     * @throws ContainerException
25
     * @throws ServiceNotFoundException
26
     */
27
    public function assembly(Rocket $rocket, Closure $next): Rocket
28
    {
29
        Logger::debug('[Alipay][Pay][H5][PayPlugin] 插件开始装载', ['rocket' => $rocket]);
30
31
        $this->loadAlipayServiceProvider($rocket);
32
33
        $rocket->setDirection(ResponseDirection::class)
34
            ->mergePayload([
35
                'method' => 'alipay.trade.wap.pay',
36
                'biz_content' => $rocket->getParams(),
37
            ]);
38
39
        Logger::info('[Alipay][Pay][H5][PayPlugin] 插件装载完毕', ['rocket' => $rocket]);
40
41
        return $next($rocket);
42
    }
43
}
44