Passed
Push — master ( 3ad41b...82578d )
by wannanbigpig
03:46 queued 10s
created

Client::unifiedTransfer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
ccs 0
cts 5
cp 0
crap 2
rs 10
1
<?php
2
/*
3
 * This file is part of the wannanbigpig/alipay-sdk-php.
4
 *
5
 * (c) wannanbigpig <[email protected]>
6
 *
7
 * This source file is subject to the MIT license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace EasyAlipay\Payment\FundAccredit;
12
13
use EasyAlipay\Payment\Kernel\BaseClient;
14
15
class Client extends BaseClient
16
{
17
    /**
18
     * alipay.fund.auth.operation.detail.query(资金授权操作查询接口).
19
     *
20
     * @param array $params
21
     *
22
     * @return array|object|\Psr\Http\Message\ResponseInterface|\WannanBigPig\Supports\Collection|\WannanBigPig\Supports\Http\Response
23
     *
24
     * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException
25
     * @throws \GuzzleHttp\Exception\GuzzleException
26
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
27
     */
28
    public function query(array $params)
29
    {
30
        $method = 'alipay.fund.auth.operation.detail.query';
31
32
        return $this->request($method, [
33
            'biz_content' => $params,
34
        ]);
35
    }
36
37
    /**
38
     * alipay.fund.auth.operation.cancel(资金授权撤销接口).
39
     *
40
     * @param array $params
41
     *
42
     * @return array|object|\Psr\Http\Message\ResponseInterface|\WannanBigPig\Supports\Collection|\WannanBigPig\Supports\Http\Response
43
     *
44
     * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException
45
     * @throws \GuzzleHttp\Exception\GuzzleException
46
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
47
     */
48
    public function cancel(array $params)
49
    {
50
        $method = 'alipay.fund.auth.operation.cancel';
51
        $this->app->setEndpointConfig($method, [
52
            'notify_url' => $this->app['config']->get('notify_url'),
53
        ]);
54
55
        return $this->request($method, [
56
            'biz_content' => $params,
57
        ]);
58
    }
59
60
    /**
61
     * alipay.fund.auth.order.freeze(资金授权冻结接口).
62
     *
63
     * @param array $params
64
     *
65
     * @return array|object|\Psr\Http\Message\ResponseInterface|\WannanBigPig\Supports\Collection|\WannanBigPig\Supports\Http\Response
66
     *
67
     * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException
68
     * @throws \GuzzleHttp\Exception\GuzzleException
69
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
70
     */
71
    public function freeze(array $params)
72
    {
73
        $method = 'alipay.fund.auth.order.freeze';
74
        $this->app->setEndpointConfig($method, [
75
            'notify_url' => $this->app['config']->get('notify_url'),
76
        ]);
77
78
        return $this->request($method, [
79
            'biz_content' => $params,
80
        ]);
81
    }
82
83
    /**
84
     * alipay.fund.auth.order.unfreeze(资金授权解冻接口).
85
     *
86
     * @param string $authNo
87
     * @param string $outRequestNo
88
     * @param string $amount
89
     * @param string $remark
90
     * @param string $extraParam
91
     *
92
     * @return array|object|\Psr\Http\Message\ResponseInterface|\WannanBigPig\Supports\Collection|\WannanBigPig\Supports\Http\Response
93
     *
94
     * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException
95
     * @throws \GuzzleHttp\Exception\GuzzleException
96
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
97
     */
98
    public function unfreeze(string $authNo, string $outRequestNo, string $amount, string $remark, string $extraParam = null)
99
    {
100
        $method = 'alipay.fund.auth.order.unfreeze';
101
        $params = array_filter([
102
            'auth_no' => $authNo,
103
            'out_request_no' => $outRequestNo,
104
            'amount' => $amount,
105
            'remark' => $remark,
106
            'extra_param' => $extraParam,
107
        ], function ($value) {
108
            return !($this->checkEmpty($value));
109
        });
110
111
        $this->app->setEndpointConfig($method, [
112
            'notify_url' => $this->app['config']->get('notify_url'),
113
        ]);
114
115
        return $this->request($method, [
116
            'biz_content' => $params,
117
        ]);
118
    }
119
120
    /**
121
     * alipay.fund.auth.order.app.freeze(线上资金授权冻结接口).
122
     *
123
     * @param array $params
124
     *
125
     * @return array|object|\Psr\Http\Message\ResponseInterface|\WannanBigPig\Supports\Collection|\WannanBigPig\Supports\Http\Response
126
     *
127
     * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException
128
     * @throws \GuzzleHttp\Exception\GuzzleException
129
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
130
     */
131
    public function onlineFreeze(array $params)
132
    {
133
        $method = 'alipay.fund.auth.order.app.freeze';
134
        $this->app->setEndpointConfig($method, [
135
            'notify_url' => $this->app['config']->get('notify_url'),
136
        ]);
137
138
        return $this->request($method, [
139
            'biz_content' => $params,
140
        ]);
141
    }
142
143
    /**
144
     * alipay.fund.auth.order.voucher.create(资金授权发码接口).
145
     *
146
     * @param array $params
147
     *
148
     * @return array|object|\Psr\Http\Message\ResponseInterface|\WannanBigPig\Supports\Collection|\WannanBigPig\Supports\Http\Response
149
     *
150
     * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException
151
     * @throws \GuzzleHttp\Exception\GuzzleException
152
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
153
     */
154
    public function getQrcode(array $params)
155
    {
156
        $method = 'alipay.fund.auth.order.voucher.create';
157
        $this->app->setEndpointConfig($method, [
158
            'notify_url' => $this->app['config']->get('notify_url'),
159
        ]);
160
161
        return $this->request($method, [
162
            'biz_content' => $params,
163
        ]);
164
    }
165
166
    /**
167
     * alipay.fund.trans.toaccount.transfer(单笔转账到支付宝账户接口).
168
     *
169
     * @param array $params
170
     *
171
     * @return array|object|\Psr\Http\Message\ResponseInterface|\WannanBigPig\Supports\Collection|\WannanBigPig\Supports\Http\Response
172
     *
173
     * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException
174
     * @throws \GuzzleHttp\Exception\GuzzleException
175
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
176
     */
177
    public function transfer(array $params)
178
    {
179
        $method = 'alipay.fund.trans.toaccount.transfer';
180
181
        return $this->request($method, [
182
            'biz_content' => $params,
183
        ]);
184
    }
185
186
    /**
187
     * alipay.fund.trans.order.query(查询转账订单接口).
188
     *
189
     * @param string      $orderId
190
     * @param string|null $outBizNo
191
     *
192
     * @return array|object|\Psr\Http\Message\ResponseInterface|\WannanBigPig\Supports\Collection|\WannanBigPig\Supports\Http\Response
193
     *
194
     * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException
195
     * @throws \GuzzleHttp\Exception\GuzzleException
196
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
197
     */
198
    public function getTransferOrder(string $orderId, string $outBizNo = null)
199
    {
200
        $method = 'alipay.fund.trans.order.query';
201
202
        $params = array_filter([
203
            'order_id' => $orderId,
204
            'out_biz_no' => $outBizNo,
205
        ], function ($value) {
206
            return !($this->checkEmpty($value));
207
        });
208
209
        return $this->request($method, [
210
            'biz_content' => $params,
211
        ]);
212
    }
213
214
    /**
215
     * alipay.fund.trans.uni.transfer(统一转账接口).
216
     *
217
     * @param array $params
218
     *
219
     * @return array|object|\Psr\Http\Message\ResponseInterface|\WannanBigPig\Supports\Collection|\WannanBigPig\Supports\Http\Response
220
     *
221
     * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException
222
     * @throws \GuzzleHttp\Exception\GuzzleException
223
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
224
     */
225
    public function unifiedTransfer(array $params)
226
    {
227
        $method = 'alipay.fund.trans.uni.transfer';
228
229
        return $this->request($method, [
230
            'biz_content' => $params,
231
        ]);
232
    }
233
234
    /**
235
     * alipay.fund.trans.refund(资金退回接口).
236
     *
237
     * @param string      $orderId
238
     * @param string      $outRequestNo
239
     * @param string      $refundAmount
240
     * @param string|null $remark
241
     *
242
     * @return array|object|\Psr\Http\Message\ResponseInterface|\WannanBigPig\Supports\Collection|\WannanBigPig\Supports\Http\Response
243
     *
244
     * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException
245
     * @throws \GuzzleHttp\Exception\GuzzleException
246
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
247
     */
248
    public function TransferBack(string $orderId, string $outRequestNo, string $refundAmount, string $remark = null)
249
    {
250
        $method = 'alipay.fund.trans.refund';
251
252
        $params = array_filter([
253
            'order_id' => $orderId,
254
            'out_request_no' => $outRequestNo,
255
            'refund_amount' => $refundAmount,
256
            'remark' => $remark,
257
        ], function ($value) {
258
            return !($this->checkEmpty($value));
259
        });
260
261
        return $this->request($method, [
262
            'biz_content' => $params,
263
        ]);
264
    }
265
266
    /**
267
     * alipay.fund.trans.app.pay(现金红包无线支付接口).
268
     *
269
     * @param array $params
270
     *
271
     * @return array|object|\Psr\Http\Message\ResponseInterface|\WannanBigPig\Supports\Collection|\WannanBigPig\Supports\Http\Response
272
     *
273
     * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException
274
     * @throws \GuzzleHttp\Exception\GuzzleException
275
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
276
     */
277
    public function cashBonus(array $params)
278
    {
279
        $method = 'alipay.fund.trans.app.pay';
280
281
        $this->app->setEndpointConfig($method, [
282
            'return_url' => $this->app['config']->get('return_url'),
283
        ]);
284
285
        return $this->request($method, [
286
            'biz_content' => $params,
287
        ]);
288
    }
289
290
    /**
291
     * alipay.fund.trans.common.query(转账业务单据查询接口).
292
     *
293
     * @param array $params
294
     *
295
     * @return array|object|\Psr\Http\Message\ResponseInterface|\WannanBigPig\Supports\Collection|\WannanBigPig\Supports\Http\Response
296
     *
297
     * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException
298
     * @throws \GuzzleHttp\Exception\GuzzleException
299
     * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException
300
     */
301
    public function transferCommonQuery(array $params)
302
    {
303
        $method = 'alipay.fund.trans.common.query';
304
305
        return $this->request($method, [
306
            'biz_content' => $params,
307
        ]);
308
    }
309
}
310