PayPlugin   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 1

1 Method

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