Passed
Push — master ( bd56ba...e02069 )
by Songda
09:11 queued 07:22
created

AgreementPageSignPlugin::assembly()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 16
rs 9.9666
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay\Plugin\Alipay\User;
6
7
use Closure;
8
use Yansongda\Pay\Contract\PluginInterface;
9
use Yansongda\Pay\Logger;
10
use Yansongda\Pay\Parser\ResponseParser;
11
use Yansongda\Pay\Rocket;
12
13
/**
14
 * @see https://opendocs.alipay.com/open/02fkan?ref=api&scene=35
15
 */
16
class AgreementPageSignPlugin implements PluginInterface
17
{
18
    public function assembly(Rocket $rocket, Closure $next): Rocket
19
    {
20
        Logger::info('[alipay][AgreementPageSignPlugin] 插件开始装载', ['rocket' => $rocket]);
21
22
        $rocket->setDirection(ResponseParser::class)
23
            ->mergePayload([
24
                'method' => 'alipay.user.agreement.page.sign',
25
                'biz_content' => array_merge(
26
                    ['product_code' => 'CYCLE_PAY_AUTH'],
27
                    $rocket->getParams()
28
                ),
29
            ]);
30
31
        Logger::info('[alipay][AgreementPageSignPlugin] 插件装载完毕', ['rocket' => $rocket]);
32
33
        return $next($rocket);
34
    }
35
}
36