Passed
Pull Request — master (#662)
by Songda
01:53
created

PagePayPlugin::getUri()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay\Plugin\Unipay\OnlineGateway;
6
7
use Yansongda\Pay\Parser\ResponseParser;
8
use Yansongda\Pay\Plugin\Unipay\GeneralPlugin;
9
use Yansongda\Pay\Rocket;
10
11
/**
12
 * @see https://open.unionpay.com/tjweb/acproduct/APIList?acpAPIId=754&apiservId=448&version=V2.2&bussType=0
13
 */
14
class PagePayPlugin extends GeneralPlugin
15
{
16
    protected function getUri(Rocket $rocket): string
17
    {
18
        return 'gateway/api/frontTransReq.do';
19
    }
20
21
    protected function doSomething(Rocket $rocket): void
22
    {
23
        $payload = [
24
            'bizType' => '000201',
25
            'txnType' => '01',
26
            'txnSubType' => '01',
27
            'channelType' => '07',
28
        ];
29
30
        if (is_null($rocket->getPayload()) || !$rocket->getPayload()->has('currencyCode')) {
31
            $payload['currencyCode'] = '156';
32
        }
33
34
        $rocket->setDirection(ResponseParser::class)
35
            ->mergePayload($payload);
36
    }
37
}
38