PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.15.4
GiveWP – Donation Plugin and Fundraising Platform v4.15.4
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / vendor / stripe / stripe-php / lib / Account.php

Account.php in GiveWP – Donation Plugin and Fundraising Platform 4.15.4, at vendor/stripe/stripe-php/lib/Account.php

431 lines 16.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // File generated from our OpenAPI spec
4
5 namespace Stripe;
6
7 /**
8 * This is an object representing a Stripe account. You can retrieve it to see
9 * properties on the account like its current e-mail address or if the account is
10 * enabled yet to make live charges.
11 *
12 * Some properties, marked below, are available only to platforms that want to <a
13 * href="https://stripe.com/docs/connect/accounts">create and manage Express or
14 * Custom accounts</a>.
15 *
16 * @property string $id Unique identifier for the object.
17 * @property string $object String representing the object's type. Objects of the same type share the same value.
18 * @property null|\Stripe\StripeObject $business_profile Business information about the account.
19 * @property null|string $business_type The business type.
20 * @property \Stripe\StripeObject $capabilities
21 * @property bool $charges_enabled Whether the account can create live charges.
22 * @property \Stripe\StripeObject $company
23 * @property \Stripe\StripeObject $controller
24 * @property string $country The account's country.
25 * @property int $created Time at which the account was connected. Measured in seconds since the Unix epoch.
26 * @property string $default_currency Three-letter ISO currency code representing the default currency for the account. This must be a currency that <a href="https://stripe.com/docs/payouts">Stripe supports in the account's country</a>.
27 * @property bool $details_submitted Whether account details have been submitted. Standard accounts cannot receive payouts before this is true.
28 * @property null|string $email An email address associated with the account. You can treat this as metadata: it is not used for authentication or messaging account holders.
29 * @property \Stripe\Collection<\Stripe\BankAccount|\Stripe\Card> $external_accounts External accounts (bank accounts and debit cards) currently attached to this account
30 * @property \Stripe\StripeObject $future_requirements
31 * @property \Stripe\Person $individual <p>This is an object representing a person associated with a Stripe account.</p><p>A platform cannot access a Standard or Express account's persons after the account starts onboarding, such as after generating an account link for the account. See the <a href="https://stripe.com/docs/connect/standard-accounts">Standard onboarding</a> or <a href="https://stripe.com/docs/connect/express-accounts">Express onboarding documentation</a> for information about platform pre-filling and account onboarding steps.</p><p>Related guide: <a href="https://stripe.com/docs/connect/identity-verification-api#person-information">Handling Identity Verification with the API</a>.</p>
32 * @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
33 * @property bool $payouts_enabled Whether Stripe can send payouts to this account.
34 * @property \Stripe\StripeObject $requirements
35 * @property null|\Stripe\StripeObject $settings Options for customizing how the account functions within Stripe.
36 * @property \Stripe\StripeObject $tos_acceptance
37 * @property string $type The Stripe account type. Can be <code>standard</code>, <code>express</code>, or <code>custom</code>.
38 */
39 class Account extends ApiResource
40 {
41 const OBJECT_NAME = 'account';
42
43 use ApiOperations\All;
44 use ApiOperations\Create;
45 use ApiOperations\Delete;
46 use ApiOperations\NestedResource;
47 use ApiOperations\Update;
48
49 const BUSINESS_TYPE_COMPANY = 'company';
50 const BUSINESS_TYPE_GOVERNMENT_ENTITY = 'government_entity';
51 const BUSINESS_TYPE_INDIVIDUAL = 'individual';
52 const BUSINESS_TYPE_NON_PROFIT = 'non_profit';
53
54 const CAPABILITY_CARD_PAYMENTS = 'card_payments';
55 const CAPABILITY_LEGACY_PAYMENTS = 'legacy_payments';
56 const CAPABILITY_PLATFORM_PAYMENTS = 'platform_payments';
57 const CAPABILITY_TRANSFERS = 'transfers';
58
59 const CAPABILITY_STATUS_ACTIVE = 'active';
60 const CAPABILITY_STATUS_INACTIVE = 'inactive';
61 const CAPABILITY_STATUS_PENDING = 'pending';
62
63 const TYPE_CUSTOM = 'custom';
64 const TYPE_EXPRESS = 'express';
65 const TYPE_STANDARD = 'standard';
66
67 use ApiOperations\Retrieve {
68 retrieve as protected _retrieve;
69 }
70
71 public static function getSavedNestedResources()
72 {
73 static $savedNestedResources = null;
74 if (null === $savedNestedResources) {
75 $savedNestedResources = new Util\Set([
76 'external_account',
77 'bank_account',
78 ]);
79 }
80
81 return $savedNestedResources;
82 }
83
84 public function instanceUrl()
85 {
86 if (null === $this['id']) {
87 return '/v1/account';
88 }
89
90 return parent::instanceUrl();
91 }
92
93 public function serializeParameters($force = false)
94 {
95 $update = parent::serializeParameters($force);
96 if (isset($this->_values['legal_entity'])) {
97 $entity = $this['legal_entity'];
98 if (isset($entity->_values['additional_owners'])) {
99 $owners = $entity['additional_owners'];
100 $entityUpdate = isset($update['legal_entity']) ? $update['legal_entity'] : [];
101 $entityUpdate['additional_owners'] = $this->serializeAdditionalOwners($entity, $owners);
102 $update['legal_entity'] = $entityUpdate;
103 }
104 }
105 if (isset($this->_values['individual'])) {
106 $individual = $this['individual'];
107 if (($individual instanceof Person) && !isset($update['individual'])) {
108 $update['individual'] = $individual->serializeParameters($force);
109 }
110 }
111
112 return $update;
113 }
114
115 private function serializeAdditionalOwners($legalEntity, $additionalOwners)
116 {
117 if (isset($legalEntity->_originalValues['additional_owners'])) {
118 $originalValue = $legalEntity->_originalValues['additional_owners'];
119 } else {
120 $originalValue = [];
121 }
122 if (($originalValue) && (\count($originalValue) > \count($additionalOwners))) {
123 throw new Exception\InvalidArgumentException(
124 'You cannot delete an item from an array, you must instead set a new array'
125 );
126 }
127
128 $updateArr = [];
129 foreach ($additionalOwners as $i => $v) {
130 $update = ($v instanceof StripeObject) ? $v->serializeParameters() : $v;
131
132 if ([] !== $update) {
133 if (!$originalValue
134 || !\array_key_exists($i, $originalValue)
135 || ($update !== $legalEntity->serializeParamsValue($originalValue[$i], null, false, true))) {
136 $updateArr[$i] = $update;
137 }
138 }
139 }
140
141 return $updateArr;
142 }
143
144 /**
145 * @param null|array|string $id the ID of the account to retrieve, or an
146 * options array containing an `id` key
147 * @param null|array|string $opts
148 *
149 * @throws \Stripe\Exception\ApiErrorException if the request fails
150 *
151 * @return \Stripe\Account
152 */
153 public static function retrieve($id = null, $opts = null)
154 {
155 if (!$opts && \is_string($id) && 'sk_' === \substr($id, 0, 3)) {
156 $opts = $id;
157 $id = null;
158 }
159
160 return self::_retrieve($id, $opts);
161 }
162
163 /**
164 * @param null|array $clientId
165 * @param null|array|string $opts
166 *
167 * @throws \Stripe\Exception\ApiErrorException if the request fails
168 *
169 * @return \Stripe\StripeObject object containing the response from the API
170 */
171 public function deauthorize($clientId = null, $opts = null)
172 {
173 $params = [
174 'client_id' => $clientId,
175 'stripe_user_id' => $this->id,
176 ];
177
178 return OAuth::deauthorize($params, $opts);
179 }
180
181 /**
182 * @param null|array $params
183 * @param null|array|string $opts
184 *
185 * @throws \Stripe\Exception\ApiErrorException if the request fails
186 *
187 * @return \Stripe\Collection<\Stripe\Person> the list of persons
188 */
189 public function persons($params = null, $opts = null)
190 {
191 $url = $this->instanceUrl() . '/persons';
192 list($response, $opts) = $this->_request('get', $url, $params, $opts);
193 $obj = Util\Util::convertToStripeObject($response, $opts);
194 $obj->setLastResponse($response);
195
196 return $obj;
197 }
198
199 /**
200 * @param null|array $params
201 * @param null|array|string $opts
202 *
203 * @throws \Stripe\Exception\ApiErrorException if the request fails
204 *
205 * @return \Stripe\Account the rejected account
206 */
207 public function reject($params = null, $opts = null)
208 {
209 $url = $this->instanceUrl() . '/reject';
210 list($response, $opts) = $this->_request('post', $url, $params, $opts);
211 $this->refreshFrom($response, $opts);
212
213 return $this;
214 }
215
216 /*
217 * Capabilities methods
218 * We can not add the capabilities() method today as the Account object already has a
219 * capabilities property which is a hash and not the sub-list of capabilities.
220 */
221
222 const PATH_CAPABILITIES = '/capabilities';
223
224 /**
225 * @param string $id the ID of the account on which to retrieve the capabilities
226 * @param null|array $params
227 * @param null|array|string $opts
228 *
229 * @throws \Stripe\Exception\ApiErrorException if the request fails
230 *
231 * @return \Stripe\Collection<\Stripe\Capability> the list of capabilities
232 */
233 public static function allCapabilities($id, $params = null, $opts = null)
234 {
235 return self::_allNestedResources($id, static::PATH_CAPABILITIES, $params, $opts);
236 }
237
238 /**
239 * @param string $id the ID of the account to which the capability belongs
240 * @param string $capabilityId the ID of the capability to retrieve
241 * @param null|array $params
242 * @param null|array|string $opts
243 *
244 * @throws \Stripe\Exception\ApiErrorException if the request fails
245 *
246 * @return \Stripe\Capability
247 */
248 public static function retrieveCapability($id, $capabilityId, $params = null, $opts = null)
249 {
250 return self::_retrieveNestedResource($id, static::PATH_CAPABILITIES, $capabilityId, $params, $opts);
251 }
252
253 /**
254 * @param string $id the ID of the account to which the capability belongs
255 * @param string $capabilityId the ID of the capability to update
256 * @param null|array $params
257 * @param null|array|string $opts
258 *
259 * @throws \Stripe\Exception\ApiErrorException if the request fails
260 *
261 * @return \Stripe\Capability
262 */
263 public static function updateCapability($id, $capabilityId, $params = null, $opts = null)
264 {
265 return self::_updateNestedResource($id, static::PATH_CAPABILITIES, $capabilityId, $params, $opts);
266 }
267 const PATH_EXTERNAL_ACCOUNTS = '/external_accounts';
268
269 /**
270 * @param string $id the ID of the account on which to retrieve the external accounts
271 * @param null|array $params
272 * @param null|array|string $opts
273 *
274 * @throws \Stripe\Exception\ApiErrorException if the request fails
275 *
276 * @return \Stripe\Collection<\Stripe\BankAccount|\Stripe\Card> the list of external accounts (BankAccount or Card)
277 */
278 public static function allExternalAccounts($id, $params = null, $opts = null)
279 {
280 return self::_allNestedResources($id, static::PATH_EXTERNAL_ACCOUNTS, $params, $opts);
281 }
282
283 /**
284 * @param string $id the ID of the account on which to create the external account
285 * @param null|array $params
286 * @param null|array|string $opts
287 *
288 * @throws \Stripe\Exception\ApiErrorException if the request fails
289 *
290 * @return \Stripe\BankAccount|\Stripe\Card
291 */
292 public static function createExternalAccount($id, $params = null, $opts = null)
293 {
294 return self::_createNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $params, $opts);
295 }
296
297 /**
298 * @param string $id the ID of the account to which the external account belongs
299 * @param string $externalAccountId the ID of the external account to delete
300 * @param null|array $params
301 * @param null|array|string $opts
302 *
303 * @throws \Stripe\Exception\ApiErrorException if the request fails
304 *
305 * @return \Stripe\BankAccount|\Stripe\Card
306 */
307 public static function deleteExternalAccount($id, $externalAccountId, $params = null, $opts = null)
308 {
309 return self::_deleteNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $opts);
310 }
311
312 /**
313 * @param string $id the ID of the account to which the external account belongs
314 * @param string $externalAccountId the ID of the external account to retrieve
315 * @param null|array $params
316 * @param null|array|string $opts
317 *
318 * @throws \Stripe\Exception\ApiErrorException if the request fails
319 *
320 * @return \Stripe\BankAccount|\Stripe\Card
321 */
322 public static function retrieveExternalAccount($id, $externalAccountId, $params = null, $opts = null)
323 {
324 return self::_retrieveNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $opts);
325 }
326
327 /**
328 * @param string $id the ID of the account to which the external account belongs
329 * @param string $externalAccountId the ID of the external account to update
330 * @param null|array $params
331 * @param null|array|string $opts
332 *
333 * @throws \Stripe\Exception\ApiErrorException if the request fails
334 *
335 * @return \Stripe\BankAccount|\Stripe\Card
336 */
337 public static function updateExternalAccount($id, $externalAccountId, $params = null, $opts = null)
338 {
339 return self::_updateNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $opts);
340 }
341 const PATH_LOGIN_LINKS = '/login_links';
342
343 /**
344 * @param string $id the ID of the account on which to create the login link
345 * @param null|array $params
346 * @param null|array|string $opts
347 *
348 * @throws \Stripe\Exception\ApiErrorException if the request fails
349 *
350 * @return \Stripe\LoginLink
351 */
352 public static function createLoginLink($id, $params = null, $opts = null)
353 {
354 return self::_createNestedResource($id, static::PATH_LOGIN_LINKS, $params, $opts);
355 }
356 const PATH_PERSONS = '/persons';
357
358 /**
359 * @param string $id the ID of the account on which to retrieve the persons
360 * @param null|array $params
361 * @param null|array|string $opts
362 *
363 * @throws \Stripe\Exception\ApiErrorException if the request fails
364 *
365 * @return \Stripe\Collection<\Stripe\Person> the list of persons
366 */
367 public static function allPersons($id, $params = null, $opts = null)
368 {
369 return self::_allNestedResources($id, static::PATH_PERSONS, $params, $opts);
370 }
371
372 /**
373 * @param string $id the ID of the account on which to create the person
374 * @param null|array $params
375 * @param null|array|string $opts
376 *
377 * @throws \Stripe\Exception\ApiErrorException if the request fails
378 *
379 * @return \Stripe\Person
380 */
381 public static function createPerson($id, $params = null, $opts = null)
382 {
383 return self::_createNestedResource($id, static::PATH_PERSONS, $params, $opts);
384 }
385
386 /**
387 * @param string $id the ID of the account to which the person belongs
388 * @param string $personId the ID of the person to delete
389 * @param null|array $params
390 * @param null|array|string $opts
391 *
392 * @throws \Stripe\Exception\ApiErrorException if the request fails
393 *
394 * @return \Stripe\Person
395 */
396 public static function deletePerson($id, $personId, $params = null, $opts = null)
397 {
398 return self::_deleteNestedResource($id, static::PATH_PERSONS, $personId, $params, $opts);
399 }
400
401 /**
402 * @param string $id the ID of the account to which the person belongs
403 * @param string $personId the ID of the person to retrieve
404 * @param null|array $params
405 * @param null|array|string $opts
406 *
407 * @throws \Stripe\Exception\ApiErrorException if the request fails
408 *
409 * @return \Stripe\Person
410 */
411 public static function retrievePerson($id, $personId, $params = null, $opts = null)
412 {
413 return self::_retrieveNestedResource($id, static::PATH_PERSONS, $personId, $params, $opts);
414 }
415
416 /**
417 * @param string $id the ID of the account to which the person belongs
418 * @param string $personId the ID of the person to update
419 * @param null|array $params
420 * @param null|array|string $opts
421 *
422 * @throws \Stripe\Exception\ApiErrorException if the request fails
423 *
424 * @return \Stripe\Person
425 */
426 public static function updatePerson($id, $personId, $params = null, $opts = null)
427 {
428 return self::_updateNestedResource($id, static::PATH_PERSONS, $personId, $params, $opts);
429 }
430 }
431