Passed
Pull Request — master (#513)
by
unknown
02:10
created

RefundPlugin::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\Wechat\Ecommerce\Refund;
6
7
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
8
use Yansongda\Pay\Rocket;
9
10
class RefundPlugin extends GeneralPlugin
11
{
12
    protected function getUri(Rocket $rocket): string
13
    {
14
        return 'v3/ecommerce/refunds/apply';
15
    }
16
17
    protected function doSomething(Rocket $rocket): void
18
    {
19
        $config = get_wechat_config($rocket->getParams());
20
21
        $wechatId = [
22
            'sp_appid' => $config->get('mini_app_id', $config->get('mp_app_id', '')),
23
        ];
24
25
        if (!$rocket->getPayload()->has('notify_url')) {
26
            $wechatId['notify_url'] = $config->get('notify_url');
27
        }
28
29
        $rocket->mergePayload($wechatId);
30
    }
31
}
32