Passed
Push — master ( 1dfbea...9713c0 )
by Songda
02:53 queued 51s
created

H5PayPlugin::assembly()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 19
rs 9.8666
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay\Plugin\Unipay\OnlineGateway;
6
7
use Closure;
8
use Yansongda\Pay\Contract\PluginInterface;
9
use Yansongda\Pay\Direction\ResponseDirection;
10
use Yansongda\Pay\Logger;
11
use Yansongda\Pay\Rocket;
12
13
/**
14
 * @see https://open.unionpay.com/tjweb/acproduct/APIList?acpAPIId=754&apiservId=448&version=V2.2&bussType=0
15
 */
16
class H5PayPlugin implements PluginInterface
17
{
18
    public function assembly(Rocket $rocket, Closure $next): Rocket
19
    {
20
        Logger::debug('[Unipay][OnlineGateway][H5PayPlugin] 插件开始装载', ['rocket' => $rocket]);
21
22
        $payload = $rocket->getPayload();
23
24
        $rocket->setDirection(ResponseDirection::class)
25
            ->mergePayload([
26
                '_url' => 'gateway/api/frontTransReq.do',
27
                'accessType' => $payload?->get('accessType') ?? '0',
28
                'bizType' => $payload?->get('bizType') ?? '000201',
29
                'txnType' => $payload?->get('txnType') ?? '01',
30
                'txnSubType' => $payload?->get('txnSubType') ?? '01',
31
                'channelType' => $payload?->get('channelType') ?? '08',
32
            ]);
33
34
        Logger::info('[Unipay][OnlineGateway][H5PayPlugin] 插件装载完毕', ['rocket' => $rocket]);
35
36
        return $next($rocket);
37
    }
38
}
39