Passed
Pull Request — master (#894)
by Songda
01:58
created

PayPlugin   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

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

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\Pay\Agreement;
6
7
use Closure;
8
use Yansongda\Pay\Contract\PluginInterface;
9
use Yansongda\Pay\Exception\ContainerException;
10
use Yansongda\Pay\Exception\ServiceNotFoundException;
11
use Yansongda\Pay\Logger;
12
use Yansongda\Pay\Rocket;
13
use Yansongda\Pay\Traits\SupportServiceProviderTrait;
14
15
/**
16
 * @see https://opendocs.alipay.com/open/38d751b1_alipay.trade.pay?pathHash=0a98c4e0&ref=api&scene=b4d9c9906e14451b99c8de390ae20fea
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][Agreement][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' => 'GENERAL_WITHHOLDING',
37
                ],
38
                $rocket->getParams(),
39
            ),
40
        ]);
41
42
        Logger::info('[Alipay][Pay][Agreement][PayPlugin] 插件装载完毕', ['rocket' => $rocket]);
43
44
        return $next($rocket);
45
    }
46
}
47