|
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\Payment\Fundflow; |
|
13
|
|
|
|
|
14
|
|
|
use EasyWeChat\Kernel\Http\StreamResponse; |
|
15
|
|
|
use EasyWeChat\Payment\Kernel\BaseClient; |
|
16
|
|
|
|
|
17
|
|
|
class Client extends BaseClient |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* Download fundflow history as a table file |
|
21
|
|
|
* |
|
22
|
|
|
* @param string $date |
|
23
|
|
|
* @param string $type |
|
24
|
|
|
* @param array $options |
|
25
|
|
|
* @return array|\EasyWeChat\Kernel\Http\Response|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
26
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException |
|
27
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
28
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
|
29
|
|
|
*/ |
|
30
|
|
|
public function get(string $date, string $type = 'Basic', $options = []) |
|
31
|
|
|
{ |
|
32
|
|
|
$params = [ |
|
33
|
|
|
'appid' => $this->app['config']->app_id, |
|
34
|
|
|
'bill_date' => $date, |
|
35
|
|
|
'account_type' => $type, |
|
36
|
|
|
'sign_type' => 'HMAC-SHA256', |
|
37
|
|
|
'nonce_str' => uniqid('micro'), |
|
38
|
|
|
]; |
|
39
|
|
|
$options = array_merge( |
|
40
|
|
|
[ |
|
41
|
|
|
'cert' => $this->app['config']->get('cert_path'), |
|
42
|
|
|
'ssl_key' => $this->app['config']->get('key_path'), |
|
43
|
|
|
], |
|
44
|
|
|
$options |
|
45
|
|
|
); |
|
46
|
|
|
$response = $this->requestRaw('pay/downloadfundflow', $params, 'post', $options); |
|
47
|
|
|
|
|
48
|
|
|
if (0 === strpos($response->getBody()->getContents(), '<xml>')) { |
|
49
|
|
|
return $this->castResponseToType($response, $this->app['config']->get('response_type')); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
return StreamResponse::buildFromPsrResponse($response); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|