1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Service\Hyperwallet; |
4
|
|
|
|
5
|
|
|
use Exception; |
6
|
|
|
use Hyperwallet\Exception\HyperwalletApiException; |
7
|
|
|
use Hyperwallet\Model\Transfer; |
8
|
|
|
use Hyperwallet\Model\TransferStatusTransition; |
9
|
|
|
use Hyperwallet\Response\ListResponse; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class TransferService |
13
|
|
|
* @package App\Service\Hyperwallet |
14
|
|
|
*/ |
15
|
|
|
class TransferService extends AbstractHyperwalletService |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @return ListResponse |
19
|
|
|
* |
20
|
|
|
* @throws HyperwalletApiException |
21
|
|
|
*/ |
22
|
|
|
public function list(): ListResponse |
23
|
|
|
{ |
24
|
|
|
return $this->client->listTransfers(); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @param array $transferDetails |
29
|
|
|
* @return Transfer | Exception |
30
|
|
|
*/ |
31
|
|
|
public function create(array $transferDetails) |
32
|
|
|
{ |
33
|
|
|
try { |
34
|
|
|
$transfer = new Transfer($transferDetails); |
35
|
|
|
return $this->client->createTransfer($transfer); |
36
|
|
|
} catch (Exception $exception) { |
37
|
|
|
return $exception; |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param string $transferToken |
43
|
|
|
* @return Exception | Transfer |
44
|
|
|
*/ |
45
|
|
|
public function get(string $transferToken) |
46
|
|
|
{ |
47
|
|
|
try { |
48
|
|
|
return $this->client->getTransfer($transferToken); |
49
|
|
|
} catch (Exception $exception) { |
50
|
|
|
return $exception; |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param string $transferToken |
56
|
|
|
* @return Exception | TransferStatusTransition |
57
|
|
|
*/ |
58
|
|
|
public function commit(string $transferToken) |
59
|
|
|
{ |
60
|
|
|
try { |
61
|
|
|
return $this->client->createTransferStatusTransition( |
62
|
|
|
$transferToken, |
63
|
|
|
(new TransferStatusTransition()) |
64
|
|
|
->setTransition("SCHEDULED") |
65
|
|
|
); |
66
|
|
|
} catch (Exception $exception) { |
67
|
|
|
return $exception; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|