Passed
Pull Request — master (#479)
by Songda
02:10 queued 12s
created

PrepayPlugin::getPartnerUri()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
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\Wechat\Pay\App;
6
7
use Yansongda\Pay\Pay;
8
use Yansongda\Pay\Rocket;
9
use Yansongda\Supports\Collection;
10
use Yansongda\Supports\Config;
11
12
class PrepayPlugin extends \Yansongda\Pay\Plugin\Wechat\Pay\Common\PrepayPlugin
13
{
14
    protected function getUri(Rocket $rocket): string
15
    {
16
        return 'v3/pay/transactions/app';
17
    }
18
19
    protected function getPartnerUri(Rocket $rocket): string
20
    {
21
        return 'v3/pay/partner/transactions/app';
22
    }
23
24
    protected function getWechatId(Config $config, Collection $payload): array
25
    {
26
        if (Pay::MODE_SERVICE == $config->get('mode')) {
27
            return [
28
                'sp_appid' => $config->get('app_id', ''),
29
                'sp_mchid' => $config->get('mch_id', ''),
30
                'sub_appid' => $payload->get('sub_appid', $config->get('sub_app_id')),
31
                'sub_mchid' => $payload->get('sub_mchid', $config->get('sub_mch_id')),
32
            ];
33
        }
34
35
        return [
36
            'appid' => $config->get('app_id', ''),
37
            'mchid' => $config->get('mch_id', ''),
38
        ];
39
    }
40
}
41