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

PosPayPlugin::assembly()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 20
rs 9.9332
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay\Plugin\Alipay\Fund\PCreditPayInstallment;
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/02np90?pathHash=d2a20943&ref=api&scene=32
17
 */
18
class PosPayPlugin 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][Fund][PCreditPayInstallment][PosPayPlugin] 插件开始装载', ['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' => 'FACE_TO_FACE_PAYMENT',
37
                    'scene' => 'bar_code',
38
                ],
39
                $rocket->getParams(),
40
            ),
41
        ]);
42
43
        Logger::info('[Alipay][Fund][PCreditPayInstallment][PosPayPlugin] 插件装载完毕', ['rocket' => $rocket]);
44
45
        return $next($rocket);
46
    }
47
}
48