1
|
|
|
<?php namespace Arcanedev\Stripe\Resources; |
2
|
|
|
|
3
|
|
|
use Arcanedev\Stripe\Contracts\Resources\Account as AccountContract; |
4
|
|
|
use Arcanedev\Stripe\StripeOAuth; |
5
|
|
|
use Arcanedev\Stripe\StripeResource; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class Account |
9
|
|
|
* |
10
|
|
|
* @package Arcanedev\Stripe\Resources |
11
|
|
|
* @author ARCANEDEV <[email protected]> |
12
|
|
|
* @link https://stripe.com/docs/api/php#account_object |
13
|
|
|
* |
14
|
|
|
* @property null id |
15
|
|
|
* @property string object // 'account' |
16
|
|
|
* @property string|null business_logo |
17
|
|
|
* @property string business_name |
18
|
|
|
* @property string|null business_url |
19
|
|
|
* @property bool charges_enabled |
20
|
|
|
* @property string country |
21
|
|
|
* @property bool debit_negative_balances // managed accounts only |
22
|
|
|
* @property \Arcanedev\Stripe\StripeObject decline_charge_on |
23
|
|
|
* @property string default_currency |
24
|
|
|
* @property bool details_submitted |
25
|
|
|
* @property string display_name |
26
|
|
|
* @property string email |
27
|
|
|
* @property \Arcanedev\Stripe\Collection external_accounts // managed accounts only |
28
|
|
|
* @property \Arcanedev\Stripe\AttachedObject legal_entity // managed accounts only |
29
|
|
|
* @property \Arcanedev\Stripe\Collection login_links |
30
|
|
|
* @property bool managed |
31
|
|
|
* @property mixed payout_schedule |
32
|
|
|
* @property mixed payout_statement_descriptor |
33
|
|
|
* @property bool payouts_enabled |
34
|
|
|
* @property string|null product_description // managed accounts only |
35
|
|
|
* @property string|null statement_descriptor |
36
|
|
|
* @property string|null support_email |
37
|
|
|
* @property string|null support_phone |
38
|
|
|
* @property string|null support_url |
39
|
|
|
* @property string timezone |
40
|
|
|
* @property \Arcanedev\Stripe\AttachedObject tos_acceptance // managed accounts only |
41
|
|
|
* @property \Arcanedev\Stripe\AttachedObject transfer_schedule // managed accounts only |
42
|
|
|
* @property bool transfers_enabled |
43
|
|
|
* @property \Arcanedev\Stripe\AttachedObject verification |
44
|
|
|
*/ |
45
|
|
|
class Account extends StripeResource implements AccountContract |
46
|
|
|
{ |
47
|
|
|
/* ----------------------------------------------------------------- |
48
|
|
|
| Constants |
49
|
|
|
| ----------------------------------------------------------------- |
50
|
|
|
*/ |
51
|
|
|
|
52
|
|
|
const PATH_EXTERNAL_ACCOUNTS = '/external_accounts'; |
53
|
|
|
const PATH_LOGIN_LINKS = '/login_links'; |
54
|
|
|
|
55
|
|
|
/* ----------------------------------------------------------------- |
56
|
|
|
| Getters & Setters |
57
|
|
|
| ----------------------------------------------------------------- |
58
|
|
|
*/ |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Get the instance url. |
62
|
|
|
* |
63
|
|
|
* @return string |
64
|
|
|
*/ |
65
|
20 |
|
public function instanceUrl() |
66
|
|
|
{ |
67
|
20 |
|
return is_null($this['id']) ? '/v1/account' : parent::instanceUrl(); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/* ------------------------------------------------------------------------------------------------ |
71
|
|
|
| Main Functions |
72
|
|
|
| ------------------------------------------------------------------------------------------------ |
73
|
|
|
*/ |
74
|
|
|
/** |
75
|
|
|
* Get all Accounts. |
76
|
|
|
* @link https://stripe.com/docs/api/php#list_accounts |
77
|
|
|
* |
78
|
|
|
* @param array|null $params |
79
|
|
|
* @param array|string|null $options |
80
|
|
|
* |
81
|
|
|
* @return \Arcanedev\Stripe\Collection|array |
82
|
|
|
*/ |
83
|
2 |
|
public static function all($params = [], $options = null) |
84
|
|
|
{ |
85
|
2 |
|
return self::scopedAll($params, $options); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Retrieve an Account. |
90
|
|
|
* @link https://stripe.com/docs/api/php#retrieve_account |
91
|
|
|
* |
92
|
|
|
* @param string|null $id |
93
|
|
|
* @param array|string|null $options |
94
|
|
|
* |
95
|
|
|
* @return self |
96
|
|
|
*/ |
97
|
12 |
|
public static function retrieve($id = null, $options = null) |
98
|
|
|
{ |
99
|
|
|
if ( |
100
|
12 |
|
! $options && |
101
|
12 |
|
is_string($id) && |
102
|
12 |
|
substr($id, 0, 3) === 'sk_' |
103
|
|
|
) { |
104
|
|
|
$options = $id; |
105
|
|
|
$id = null; |
106
|
|
|
} |
107
|
|
|
|
108
|
12 |
|
return self::scopedRetrieve($id, $options); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Create an Account. |
113
|
|
|
* @link https://stripe.com/docs/api/php#create_account |
114
|
|
|
* |
115
|
|
|
* @param array|null $params |
116
|
|
|
* @param array|string|null $options |
117
|
|
|
* |
118
|
|
|
* @return self |
119
|
|
|
*/ |
120
|
22 |
|
public static function create($params = [], $options = null) |
121
|
|
|
{ |
122
|
22 |
|
return self::scopedCreate($params, $options); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Update an Account. |
127
|
|
|
* @link https://stripe.com/docs/api/php#update_account |
128
|
|
|
* |
129
|
|
|
* @param string $id |
130
|
|
|
* @param array|null $params |
131
|
|
|
* @param array|string|null $options |
132
|
|
|
* |
133
|
|
|
* @return self |
134
|
|
|
*/ |
135
|
2 |
|
public static function update($id, $params = [], $options = null) |
136
|
|
|
{ |
137
|
2 |
|
return self::scopedUpdate($id, $params, $options); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Update/Save an Account. |
142
|
|
|
* @link https://stripe.com/docs/api/php#update_account |
143
|
|
|
* |
144
|
|
|
* @param array|string|null $options |
145
|
|
|
* |
146
|
|
|
* @return self |
147
|
|
|
*/ |
148
|
4 |
|
public function save($options = null) |
149
|
|
|
{ |
150
|
4 |
|
return $this->scopedSave($options); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Delete an Account. |
155
|
|
|
* @link https://stripe.com/docs/api/php#delete_account |
156
|
|
|
* |
157
|
|
|
* @param array|null $params |
158
|
|
|
* @param array|string|null $options |
159
|
|
|
* |
160
|
|
|
* @return self |
161
|
|
|
*/ |
162
|
2 |
|
public function delete($params = [], $options = null) |
163
|
|
|
{ |
164
|
2 |
|
return $this->scopedDelete($params, $options); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Reject an Account. |
169
|
|
|
* @link https://stripe.com/docs/api/php#reject_account |
170
|
|
|
* |
171
|
|
|
* @param array|null $params |
172
|
|
|
* @param array|string|null $options |
173
|
|
|
* |
174
|
|
|
* @return self |
175
|
|
|
*/ |
176
|
2 |
|
public function reject($params = [], $options = null) |
177
|
|
|
{ |
178
|
2 |
|
return $this->scopedPostCall( |
179
|
2 |
|
$this->instanceUrl() . '/reject', $params, $options |
180
|
|
|
); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* Deauthorize the account. |
185
|
|
|
* |
186
|
|
|
* @param array|null $clientId |
187
|
|
|
* @param array|string|null $options |
188
|
|
|
* |
189
|
|
|
* @return \Arcanedev\Stripe\StripeObject |
190
|
|
|
*/ |
191
|
2 |
|
public function deauthorize($clientId = null, $options = null) |
192
|
|
|
{ |
193
|
|
|
$params = [ |
194
|
2 |
|
'client_id' => $clientId, |
195
|
2 |
|
'stripe_user_id' => $this->id, |
196
|
|
|
]; |
197
|
|
|
|
198
|
2 |
|
return StripeOAuth::deauthorize($params, $options); |
|
|
|
|
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* Create an external account. |
203
|
|
|
* |
204
|
|
|
* @param string $id |
205
|
|
|
* @param array|null $params |
206
|
|
|
* @param array|string|null $options |
207
|
|
|
* |
208
|
|
|
* @return \Arcanedev\Stripe\Bases\ExternalAccount |
209
|
|
|
*/ |
210
|
2 |
|
public static function createExternalAccount($id, $params = null, $options = null) |
211
|
|
|
{ |
212
|
2 |
|
return self::createNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $params, $options); |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* Retrieve an external account. |
217
|
|
|
* |
218
|
|
|
* @param string $id |
219
|
|
|
* @param string $externalAccountId |
220
|
|
|
* @param array|null $params |
221
|
|
|
* @param array|string|null $options |
222
|
|
|
* |
223
|
|
|
* @return \Arcanedev\Stripe\Bases\ExternalAccount |
224
|
|
|
*/ |
225
|
2 |
|
public static function retrieveExternalAccount($id, $externalAccountId, $params = null, $options = null) |
226
|
|
|
{ |
227
|
2 |
|
return self::retrieveNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $options); |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* Update an external account. |
232
|
|
|
* |
233
|
|
|
* @param string $id |
234
|
|
|
* @param string $externalAccountId |
235
|
|
|
* @param array|null $params |
236
|
|
|
* @param array|string|null $options |
237
|
|
|
* |
238
|
|
|
* @return \Arcanedev\Stripe\Bases\ExternalAccount |
239
|
|
|
*/ |
240
|
2 |
|
public static function updateExternalAccount($id, $externalAccountId, $params = null, $options = null) |
241
|
|
|
{ |
242
|
2 |
|
return self::updateNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $options); |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* Delete an external account. |
247
|
|
|
* |
248
|
|
|
* @param string $id |
249
|
|
|
* @param string $externalAccountId |
250
|
|
|
* @param array|null $params |
251
|
|
|
* @param array|string|null $options |
252
|
|
|
* |
253
|
|
|
* @return \Arcanedev\Stripe\Bases\ExternalAccount |
254
|
|
|
*/ |
255
|
2 |
|
public static function deleteExternalAccount($id, $externalAccountId, $params = null, $options = null) |
256
|
|
|
{ |
257
|
2 |
|
return self::deleteNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $options); |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
/** |
261
|
|
|
* Get all the external accounts. |
262
|
|
|
* |
263
|
|
|
* @param string $id |
264
|
|
|
* @param array|null $params |
265
|
|
|
* @param array|string|null $options |
266
|
|
|
* |
267
|
|
|
* @return \Arcanedev\Stripe\Collection |
268
|
|
|
*/ |
269
|
2 |
|
public static function allExternalAccounts($id, $params = null, $options = null) |
270
|
|
|
{ |
271
|
2 |
|
return self::allNestedResources($id, static::PATH_EXTERNAL_ACCOUNTS, $params, $options); |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* Create a login link. |
276
|
|
|
* |
277
|
|
|
* @link https://stripe.com/docs/api#create_login_link |
278
|
|
|
* |
279
|
|
|
* @param string $id |
280
|
|
|
* @param array|null $params |
281
|
|
|
* @param array|string|null $options |
282
|
|
|
* |
283
|
|
|
* @return \Arcanedev\Stripe\Resources\LoginLink |
284
|
|
|
*/ |
285
|
2 |
|
public static function createLoginLink($id, $params = null, $options = null) |
286
|
|
|
{ |
287
|
2 |
|
return self::createNestedResource($id, static::PATH_LOGIN_LINKS, $params, $options); |
288
|
|
|
} |
289
|
|
|
} |
290
|
|
|
|
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.