-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWireTransfersService.php
More file actions
204 lines (187 loc) · 7.79 KB
/
WireTransfersService.php
File metadata and controls
204 lines (187 loc) · 7.79 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?php
declare(strict_types=1);
namespace Increase\Services;
use Increase\Client;
use Increase\Core\Exceptions\APIException;
use Increase\Core\Util;
use Increase\Page;
use Increase\RequestOptions;
use Increase\ServiceContracts\WireTransfersContract;
use Increase\WireTransfers\WireTransfer;
use Increase\WireTransfers\WireTransferCreateParams\Creditor;
use Increase\WireTransfers\WireTransferCreateParams\Debtor;
use Increase\WireTransfers\WireTransferCreateParams\Remittance;
use Increase\WireTransfers\WireTransferListParams\CreatedAt;
use Increase\WireTransfers\WireTransferListParams\Status;
/**
* @phpstan-import-type CreditorShape from \Increase\WireTransfers\WireTransferCreateParams\Creditor
* @phpstan-import-type RemittanceShape from \Increase\WireTransfers\WireTransferCreateParams\Remittance
* @phpstan-import-type DebtorShape from \Increase\WireTransfers\WireTransferCreateParams\Debtor
* @phpstan-import-type CreatedAtShape from \Increase\WireTransfers\WireTransferListParams\CreatedAt
* @phpstan-import-type StatusShape from \Increase\WireTransfers\WireTransferListParams\Status
* @phpstan-import-type RequestOpts from \Increase\RequestOptions
*/
final class WireTransfersService implements WireTransfersContract
{
/**
* @api
*/
public WireTransfersRawService $raw;
/**
* @internal
*/
public function __construct(private Client $client)
{
$this->raw = new WireTransfersRawService($client);
}
/**
* @api
*
* Create a Wire Transfer
*
* @param string $accountID the identifier for the account that will send the transfer
* @param int $amount the transfer amount in USD cents
* @param Creditor|CreditorShape $creditor the person or business that is receiving the funds from the transfer
* @param Remittance|RemittanceShape $remittance additional remittance information related to the wire transfer
* @param string $accountNumber the account number for the destination account
* @param Debtor|DebtorShape $debtor The person or business whose funds are being transferred. This is only necessary if you're transferring from a commingled account. Otherwise, we'll use the associated entity's details.
* @param string $externalAccountID The ID of an External Account to initiate a transfer to. If this parameter is provided, `account_number` and `routing_number` must be absent.
* @param string $inboundWireDrawdownRequestID the ID of an Inbound Wire Drawdown Request in response to which this transfer is being sent
* @param bool $requireApproval whether the transfer requires explicit approval via the dashboard or API
* @param string $routingNumber the American Bankers' Association (ABA) Routing Transit Number (RTN) for the destination account
* @param string $sourceAccountNumberID The ID of an Account Number that will be passed to the wire's recipient
* @param RequestOpts|null $requestOptions
*
* @throws APIException
*/
public function create(
string $accountID,
int $amount,
Creditor|array $creditor,
Remittance|array $remittance,
?string $accountNumber = null,
Debtor|array|null $debtor = null,
?string $externalAccountID = null,
?string $inboundWireDrawdownRequestID = null,
?bool $requireApproval = null,
?string $routingNumber = null,
?string $sourceAccountNumberID = null,
RequestOptions|array|null $requestOptions = null,
): WireTransfer {
$params = Util::removeNulls(
[
'accountID' => $accountID,
'amount' => $amount,
'creditor' => $creditor,
'remittance' => $remittance,
'accountNumber' => $accountNumber,
'debtor' => $debtor,
'externalAccountID' => $externalAccountID,
'inboundWireDrawdownRequestID' => $inboundWireDrawdownRequestID,
'requireApproval' => $requireApproval,
'routingNumber' => $routingNumber,
'sourceAccountNumberID' => $sourceAccountNumberID,
],
);
// @phpstan-ignore-next-line argument.type
$response = $this->raw->create(params: $params, requestOptions: $requestOptions);
return $response->parse();
}
/**
* @api
*
* Retrieve a Wire Transfer
*
* @param string $wireTransferID the identifier of the Wire Transfer
* @param RequestOpts|null $requestOptions
*
* @throws APIException
*/
public function retrieve(
string $wireTransferID,
RequestOptions|array|null $requestOptions = null
): WireTransfer {
// @phpstan-ignore-next-line argument.type
$response = $this->raw->retrieve($wireTransferID, requestOptions: $requestOptions);
return $response->parse();
}
/**
* @api
*
* List Wire Transfers
*
* @param string $accountID filter Wire Transfers to those belonging to the specified Account
* @param CreatedAt|CreatedAtShape $createdAt
* @param string $cursor return the page of entries after this one
* @param string $externalAccountID filter Wire Transfers to those made to the specified External Account
* @param string $idempotencyKey Filter records to the one with the specified `idempotency_key` you chose for that object. This value is unique across Increase and is used to ensure that a request is only processed once. Learn more about [idempotency](https://increase.com/documentation/idempotency-keys).
* @param int $limit Limit the size of the list that is returned. The default (and maximum) is 100 objects.
* @param Status|StatusShape $status
* @param RequestOpts|null $requestOptions
*
* @return Page<WireTransfer>
*
* @throws APIException
*/
public function list(
?string $accountID = null,
CreatedAt|array|null $createdAt = null,
?string $cursor = null,
?string $externalAccountID = null,
?string $idempotencyKey = null,
?int $limit = null,
Status|array|null $status = null,
RequestOptions|array|null $requestOptions = null,
): Page {
$params = Util::removeNulls(
[
'accountID' => $accountID,
'createdAt' => $createdAt,
'cursor' => $cursor,
'externalAccountID' => $externalAccountID,
'idempotencyKey' => $idempotencyKey,
'limit' => $limit,
'status' => $status,
],
);
// @phpstan-ignore-next-line argument.type
$response = $this->raw->list(params: $params, requestOptions: $requestOptions);
return $response->parse();
}
/**
* @api
*
* Approve a Wire Transfer
*
* @param string $wireTransferID the identifier of the Wire Transfer to approve
* @param RequestOpts|null $requestOptions
*
* @throws APIException
*/
public function approve(
string $wireTransferID,
RequestOptions|array|null $requestOptions = null
): WireTransfer {
// @phpstan-ignore-next-line argument.type
$response = $this->raw->approve($wireTransferID, requestOptions: $requestOptions);
return $response->parse();
}
/**
* @api
*
* Cancel a pending Wire Transfer
*
* @param string $wireTransferID the identifier of the pending Wire Transfer to cancel
* @param RequestOpts|null $requestOptions
*
* @throws APIException
*/
public function cancel(
string $wireTransferID,
RequestOptions|array|null $requestOptions = null
): WireTransfer {
// @phpstan-ignore-next-line argument.type
$response = $this->raw->cancel($wireTransferID, requestOptions: $requestOptions);
return $response->parse();
}
}