Passed
Pull Request — master (#1604)
by
unknown
03:16
created

InvoiceClient::setBizattr()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: birjemin
5
 * Date: 2019/7/15
6
 * Time: 10:29
7
 */
8
9
namespace EasyWeChat\OfficialAccount\Card;
10
11
12
use EasyWeChat\Kernel\BaseClient;
13
14
/**
15
 * Class InvoiceClient.
16
 *
17
 * @author overtrue <[email protected]>
18
 */
19
class InvoiceClient extends BaseClient
20
{
21
    /**
22
     * 设置支付后开票信息接口
23
     *
24
     * @param string $mchid
25
     * @param string $sPappid
26
     *
27
     * @return mixed
28
     */
29 1
    public function set(string $mchid, string $sPappid)
30
    {
31
        $params = [
32
            'paymch_info' => [
33 1
                'mchid'    => $mchid,
34 1
                's_pappid' => $sPappid,
35
            ],
36
        ];
37 1
        return $this->setBizattr('set_pay_mch', $params);
38
    }
39
40
    /**
41
     * 查询支付后开票信息接口
42
     *
43
     * @return mixed
44
     */
45 1
    public function get()
46
    {
47 1
        return $this->setBizattr('get_pay_mch');
48
    }
49
50
    /**
51
     * 设置授权页字段信息接口
52
     *
53
     * @param array $userData
54
     * @param array $bizData
55
     *
56
     * @return mixed
57
     */
58 1
    public function setAuthField(array $userData, array $bizData)
59
    {
60
        $params = [
61
            'auth_field' => [
62 1
                'user_field' => $userData,
63 1
                'biz_field'  => $bizData,
64
            ],
65
        ];
66 1
        return $this->setBizattr('set_auth_field', $params);
67
    }
68
69
    /**
70
     * 查询授权页字段信息接口
71
     *
72
     * @return mixed
73
     */
74 1
    public function getAuthField()
75
    {
76 1
        return $this->setBizattr('get_auth_field');
77
    }
78
79
    /**
80
     * 查询开票信息
81
     *
82
     * @param string $orderId
83
     * @param string $appId
84
     *
85
     * @return mixed
86
     */
87 1
    public function getAuthData(string $appId, string $orderId)
88
    {
89
        $params = [
90 1
            'order_id' => $orderId,
91 1
            's_appid'  => $appId
92
        ];
93 1
        return $this->httpPost('card/invoice/getauthdata', $params);
94
    }
95
96
    /**
97
     * @param string $action
98
     * @param array $params
99
     *
100
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
101
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
102
     */
103 4
    private function setBizattr(string $action, array $params = [])
104
    {
105 4
        return $this->httpPostJson('card/invoice/setbizattr', $params, ['action' => $action]);
106
    }
107
}