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

H5PayPlugin   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 13
c 1
b 0
f 0
dl 0
loc 21
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\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