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

RefundPlugin   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getUri() 0 3 1
A doSomething() 0 13 2
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