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
|
2 |
|
public function query(array $params) |
29
|
|
|
{ |
30
|
2 |
|
$method = 'alipay.fund.auth.operation.detail.query'; |
31
|
|
|
|
32
|
2 |
|
return $this->request($method, [ |
33
|
2 |
|
'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
|
2 |
|
public function cancel(array $params) |
49
|
|
|
{ |
50
|
2 |
|
$method = 'alipay.fund.auth.operation.cancel'; |
51
|
2 |
|
$this->app->setEndpointConfig($method, [ |
52
|
2 |
|
'notify_url' => $this->app['config']->get('notify_url'), |
53
|
|
|
]); |
54
|
|
|
|
55
|
2 |
|
return $this->request($method, [ |
56
|
2 |
|
'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
|
2 |
|
public function freeze(array $params) |
72
|
|
|
{ |
73
|
2 |
|
$method = 'alipay.fund.auth.order.freeze'; |
74
|
2 |
|
$this->app->setEndpointConfig($method, [ |
75
|
2 |
|
'notify_url' => $this->app['config']->get('notify_url'), |
76
|
|
|
]); |
77
|
|
|
|
78
|
2 |
|
return $this->request($method, [ |
79
|
2 |
|
'biz_content' => $params, |
80
|
|
|
]); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* alipay.fund.auth.order.unfreeze(资金授权解冻接口). |
85
|
|
|
* |
86
|
|
|
* @param string $authNo |
87
|
|
|
* @param string $outRequestNo |
88
|
|
|
* @param float $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
|
2 |
|
public function unfreeze(string $authNo, string $outRequestNo, float $amount, string $remark, string $extraParam = null) |
99
|
|
|
{ |
100
|
2 |
|
$method = 'alipay.fund.auth.order.unfreeze'; |
101
|
2 |
|
$params = array_filter([ |
102
|
2 |
|
'auth_no' => $authNo, |
103
|
2 |
|
'out_request_no' => $outRequestNo, |
104
|
2 |
|
'amount' => $amount, |
105
|
2 |
|
'remark' => $remark, |
106
|
2 |
|
'extra_param' => $extraParam, |
107
|
2 |
|
], function ($value) { |
108
|
2 |
|
return !($this->checkEmpty($value)); |
109
|
2 |
|
}); |
110
|
|
|
|
111
|
2 |
|
$this->app->setEndpointConfig($method, [ |
112
|
2 |
|
'notify_url' => $this->app['config']->get('notify_url'), |
113
|
|
|
]); |
114
|
|
|
|
115
|
2 |
|
return $this->request($method, [ |
116
|
2 |
|
'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
|
2 |
|
public function onlineFreeze(array $params) |
132
|
|
|
{ |
133
|
2 |
|
$method = 'alipay.fund.auth.order.app.freeze'; |
134
|
2 |
|
$this->app->setEndpointConfig($method, [ |
135
|
2 |
|
'notify_url' => $this->app['config']->get('notify_url'), |
136
|
|
|
]); |
137
|
|
|
|
138
|
2 |
|
return $this->request($method, [ |
139
|
2 |
|
'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
|
2 |
|
public function getQrcode(array $params) |
155
|
|
|
{ |
156
|
2 |
|
$method = 'alipay.fund.auth.order.voucher.create'; |
157
|
2 |
|
$this->app->setEndpointConfig($method, [ |
158
|
2 |
|
'notify_url' => $this->app['config']->get('notify_url'), |
159
|
|
|
]); |
160
|
|
|
|
161
|
2 |
|
return $this->request($method, [ |
162
|
2 |
|
'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
|
2 |
|
public function transfer(array $params) |
178
|
|
|
{ |
179
|
2 |
|
$method = 'alipay.fund.trans.toaccount.transfer'; |
180
|
|
|
|
181
|
2 |
|
return $this->request($method, [ |
182
|
2 |
|
'biz_content' => $params, |
183
|
|
|
]); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* alipay.fund.trans.order.query(查询转账订单接口). |
188
|
|
|
* |
189
|
|
|
* @param string $outBizNo |
190
|
|
|
* @param string|null $orderId |
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
|
2 |
|
public function getTransferOrder(string $outBizNo, string $orderId = null) |
199
|
|
|
{ |
200
|
2 |
|
$method = 'alipay.fund.trans.order.query'; |
201
|
|
|
|
202
|
2 |
|
$params = array_filter([ |
203
|
2 |
|
'order_id' => $orderId, |
204
|
2 |
|
'out_biz_no' => $outBizNo, |
205
|
2 |
|
], function ($value) { |
206
|
2 |
|
return !($this->checkEmpty($value)); |
207
|
2 |
|
}); |
208
|
|
|
|
209
|
2 |
|
return $this->request($method, [ |
210
|
2 |
|
'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
|
2 |
|
public function unifiedTransfer(array $params) |
226
|
|
|
{ |
227
|
2 |
|
$method = 'alipay.fund.trans.uni.transfer'; |
228
|
|
|
|
229
|
2 |
|
return $this->request($method, [ |
230
|
2 |
|
'biz_content' => $params, |
231
|
|
|
]); |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* alipay.fund.trans.refund(资金退回接口). |
236
|
|
|
* |
237
|
|
|
* @param string $orderId |
238
|
|
|
* @param string $outRequestNo |
239
|
|
|
* @param float $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
|
2 |
|
public function transferBack(string $orderId, string $outRequestNo, float $refundAmount, string $remark = null) |
249
|
|
|
{ |
250
|
2 |
|
$method = 'alipay.fund.trans.refund'; |
251
|
|
|
|
252
|
2 |
|
$params = array_filter([ |
253
|
2 |
|
'order_id' => $orderId, |
254
|
2 |
|
'out_request_no' => $outRequestNo, |
255
|
2 |
|
'refund_amount' => $refundAmount, |
256
|
2 |
|
'remark' => $remark, |
257
|
2 |
|
], function ($value) { |
258
|
2 |
|
return !($this->checkEmpty($value)); |
259
|
2 |
|
}); |
260
|
|
|
|
261
|
2 |
|
return $this->request($method, [ |
262
|
2 |
|
'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
|
2 |
|
public function cashBonus(array $params) |
278
|
|
|
{ |
279
|
2 |
|
$method = 'alipay.fund.trans.app.pay'; |
280
|
|
|
|
281
|
2 |
|
$this->app->setEndpointConfig($method, [ |
282
|
2 |
|
'return_url' => $this->app['config']->get('return_url'), |
283
|
|
|
]); |
284
|
|
|
|
285
|
2 |
|
return $this->request($method, [ |
286
|
2 |
|
'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
|
2 |
|
public function transferCommonQuery(array $params) |
302
|
|
|
{ |
303
|
2 |
|
$method = 'alipay.fund.trans.common.query'; |
304
|
|
|
|
305
|
2 |
|
return $this->request($method, [ |
306
|
2 |
|
'biz_content' => $params, |
307
|
|
|
]); |
308
|
|
|
} |
309
|
|
|
} |
310
|
|
|
|