PayPlugin   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A assembly() 0 20 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay\Plugin\Alipay\V2\Pay\Web;
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/59da99d0_alipay.trade.page.pay?pathHash=8e24911d&ref=api&scene=22
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][Web][PayPlugin] 插件开始装载', ['rocket' => $rocket]);
30
31
        $this->loadAlipayServiceProvider($rocket);
32
33
        $rocket->setDirection(ResponseDirection::class)
34
            ->mergePayload([
35
                'method' => 'alipay.trade.page.pay',
36
                'biz_content' => array_merge(
37
                    [
38
                        'product_code' => 'FAST_INSTANT_TRADE_PAY',
39
                    ],
40
                    $rocket->getParams()
41
                ),
42
            ]);
43
44
        Logger::info('[Alipay][Pay][Web][PayPlugin] 插件装载完毕', ['rocket' => $rocket]);
45
46
        return $next($rocket);
47
    }
48
}
49