TransferGateway.php
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace Yansongda\Pay\Gateways\Alipay;
use Yansongda\Pay\Contracts\GatewayInterface;
use Yansongda\Pay\Events;
use Yansongda\Pay\Exceptions\GatewayException;
use Yansongda\Pay\Exceptions\InvalidConfigException;
use Yansongda\Pay\Exceptions\InvalidSignException;
use Yansongda\Supports\Collection;
class TransferGateway implements GatewayInterface
{
/**
* Pay an order.
*
* @author yansongda <me@yansongda.cn>
*
* @param string $endpoint
*
* @throws GatewayException
* @throws InvalidConfigException
* @throws InvalidSignException
*/
public function pay($endpoint, array $payload): Collection
{
$payload['method'] = 'alipay.fund.trans.uni.transfer';
$payload['sign'] = Support::generateSign($payload);
Events::dispatch(new Events\PayStarted('Alipay', 'Transfer', $endpoint, $payload));
return Support::requestApi($payload);
}
/**
* Find.
*
* @author yansongda <me@yansongda.cn>
*
* @param $order
*/
public function find($order): array
{
return [
'method' => 'alipay.fund.trans.order.query',
'biz_content' => json_encode(is_array($order) ? $order : ['out_biz_no' => $order]),
];
}
}