Passed
Push — master ( be4655...e9d8d4 )
by Carlos
03:27
created

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