PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / vendor / stripe / stripe-php / lib / Account.php

Account.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at vendor/stripe/stripe-php/lib/Account.php

398 lines 15.5 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 TYPE_CUSTOM = 'custom';
55 const TYPE_EXPRESS = 'express';
56 const TYPE_STANDARD = 'standard';
57
58 use ApiOperations\Retrieve {
59 retrieve as protected _retrieve;
60 }
61
62 public static function getSavedNestedResources()
63 {
64 static $savedNestedResources = null;
65 if (null === $savedNestedResources) {
66 $savedNestedResources = new Util\Set([
67 'external_account',
68 'bank_account',
69 ]);
70 }
71
72 return $savedNestedResources;
73 }
74
75 public function instanceUrl()
76 {
77 if (null === $this['id']) {
78 return '/v1/account';
79 }
80
81 return parent::instanceUrl();
82 }
83
84 /**
85 * @param null|array|string $id the ID of the account to retrieve, or an
86 * options array containing an `id` key
87 * @param null|array|string $opts
88 *
89 * @throws \Stripe\Exception\ApiErrorException if the request fails
90 *
91 * @return \Stripe\Account
92 */
93 public static function retrieve($id = null, $opts = null)
94 {
95 if (!$opts && \is_string($id) && 'sk_' === \substr($id, 0, 3)) {
96 $opts = $id;
97 $id = null;
98 }
99
100 return self::_retrieve($id, $opts);
101 }
102
103 public function serializeParameters($force = false)
104 {
105 $update = parent::serializeParameters($force);
106 if (isset($this->_values['legal_entity'])) {
107 $entity = $this['legal_entity'];
108 if (isset($entity->_values['additional_owners'])) {
109 $owners = $entity['additional_owners'];
110 $entityUpdate = isset($update['legal_entity']) ? $update['legal_entity'] : [];
111 $entityUpdate['additional_owners'] = $this->serializeAdditionalOwners($entity, $owners);
112 $update['legal_entity'] = $entityUpdate;
113 }
114 }
115 if (isset($this->_values['individual'])) {
116 $individual = $this['individual'];
117 if (($individual instanceof Person) && !isset($update['individual'])) {
118 $update['individual'] = $individual->serializeParameters($force);
119 }
120 }
121
122 return $update;
123 }
124
125 private function serializeAdditionalOwners($legalEntity, $additionalOwners)
126 {
127 if (isset($legalEntity->_originalValues['additional_owners'])) {
128 $originalValue = $legalEntity->_originalValues['additional_owners'];
129 } else {
130 $originalValue = [];
131 }
132 if (($originalValue) && (\count($originalValue) > \count($additionalOwners))) {
133 throw new Exception\InvalidArgumentException(
134 'You cannot delete an item from an array, you must instead set a new array'
135 );
136 }
137
138 $updateArr = [];
139 foreach ($additionalOwners as $i => $v) {
140 $update = ($v instanceof StripeObject) ? $v->serializeParameters() : $v;
141
142 if ([] !== $update) {
143 if (!$originalValue
144 || !\array_key_exists($i, $originalValue)
145 || ($update !== $legalEntity->serializeParamsValue($originalValue[$i], null, false, true))) {
146 $updateArr[$i] = $update;
147 }
148 }
149 }
150
151 return $updateArr;
152 }
153
154 /**
155 * @param null|array $clientId
156 * @param null|array|string $opts
157 *
158 * @throws \Stripe\Exception\ApiErrorException if the request fails
159 *
160 * @return \Stripe\StripeObject object containing the response from the API
161 */
162 public function deauthorize($clientId = null, $opts = null)
163 {
164 $params = [
165 'client_id' => $clientId,
166 'stripe_user_id' => $this->id,
167 ];
168
169 return OAuth::deauthorize($params, $opts);
170 }
171
172 /**
173 * @param null|array $params
174 * @param null|array|string $opts
175 *
176 * @throws \Stripe\Exception\ApiErrorException if the request fails
177 *
178 * @return \Stripe\Account the rejected account
179 */
180 public function reject($params = null, $opts = null)
181 {
182 $url = $this->instanceUrl() . '/reject';
183 list($response, $opts) = $this->_request('post', $url, $params, $opts);
184 $this->refreshFrom($response, $opts);
185
186 return $this;
187 }
188
189 const PATH_CAPABILITIES = '/capabilities';
190
191 /**
192 * @param string $id the ID of the account on which to retrieve the capabilities
193 * @param null|array $params
194 * @param null|array|string $opts
195 *
196 * @throws \Stripe\Exception\ApiErrorException if the request fails
197 *
198 * @return \Stripe\Collection<\Stripe\Capability> the list of capabilities
199 */
200 public static function allCapabilities($id, $params = null, $opts = null)
201 {
202 return self::_allNestedResources($id, static::PATH_CAPABILITIES, $params, $opts);
203 }
204
205 /**
206 * @param string $id the ID of the account to which the capability belongs
207 * @param string $capabilityId the ID of the capability to retrieve
208 * @param null|array $params
209 * @param null|array|string $opts
210 *
211 * @throws \Stripe\Exception\ApiErrorException if the request fails
212 *
213 * @return \Stripe\Capability
214 */
215 public static function retrieveCapability($id, $capabilityId, $params = null, $opts = null)
216 {
217 return self::_retrieveNestedResource($id, static::PATH_CAPABILITIES, $capabilityId, $params, $opts);
218 }
219
220 /**
221 * @param string $id the ID of the account to which the capability belongs
222 * @param string $capabilityId the ID of the capability to update
223 * @param null|array $params
224 * @param null|array|string $opts
225 *
226 * @throws \Stripe\Exception\ApiErrorException if the request fails
227 *
228 * @return \Stripe\Capability
229 */
230 public static function updateCapability($id, $capabilityId, $params = null, $opts = null)
231 {
232 return self::_updateNestedResource($id, static::PATH_CAPABILITIES, $capabilityId, $params, $opts);
233 }
234 const PATH_EXTERNAL_ACCOUNTS = '/external_accounts';
235
236 /**
237 * @param string $id the ID of the account on which to retrieve the external accounts
238 * @param null|array $params
239 * @param null|array|string $opts
240 *
241 * @throws \Stripe\Exception\ApiErrorException if the request fails
242 *
243 * @return \Stripe\Collection<\Stripe\BankAccount|\Stripe\Card> the list of external accounts (BankAccount or Card)
244 */
245 public static function allExternalAccounts($id, $params = null, $opts = null)
246 {
247 return self::_allNestedResources($id, static::PATH_EXTERNAL_ACCOUNTS, $params, $opts);
248 }
249
250 /**
251 * @param string $id the ID of the account on which to create the external account
252 * @param null|array $params
253 * @param null|array|string $opts
254 *
255 * @throws \Stripe\Exception\ApiErrorException if the request fails
256 *
257 * @return \Stripe\BankAccount|\Stripe\Card
258 */
259 public static function createExternalAccount($id, $params = null, $opts = null)
260 {
261 return self::_createNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $params, $opts);
262 }
263
264 /**
265 * @param string $id the ID of the account to which the external account belongs
266 * @param string $externalAccountId the ID of the external account to delete
267 * @param null|array $params
268 * @param null|array|string $opts
269 *
270 * @throws \Stripe\Exception\ApiErrorException if the request fails
271 *
272 * @return \Stripe\BankAccount|\Stripe\Card
273 */
274 public static function deleteExternalAccount($id, $externalAccountId, $params = null, $opts = null)
275 {
276 return self::_deleteNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $opts);
277 }
278
279 /**
280 * @param string $id the ID of the account to which the external account belongs
281 * @param string $externalAccountId the ID of the external account to retrieve
282 * @param null|array $params
283 * @param null|array|string $opts
284 *
285 * @throws \Stripe\Exception\ApiErrorException if the request fails
286 *
287 * @return \Stripe\BankAccount|\Stripe\Card
288 */
289 public static function retrieveExternalAccount($id, $externalAccountId, $params = null, $opts = null)
290 {
291 return self::_retrieveNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $opts);
292 }
293
294 /**
295 * @param string $id the ID of the account to which the external account belongs
296 * @param string $externalAccountId the ID of the external account to update
297 * @param null|array $params
298 * @param null|array|string $opts
299 *
300 * @throws \Stripe\Exception\ApiErrorException if the request fails
301 *
302 * @return \Stripe\BankAccount|\Stripe\Card
303 */
304 public static function updateExternalAccount($id, $externalAccountId, $params = null, $opts = null)
305 {
306 return self::_updateNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $opts);
307 }
308 const PATH_LOGIN_LINKS = '/login_links';
309
310 /**
311 * @param string $id the ID of the account on which to create the login link
312 * @param null|array $params
313 * @param null|array|string $opts
314 *
315 * @throws \Stripe\Exception\ApiErrorException if the request fails
316 *
317 * @return \Stripe\LoginLink
318 */
319 public static function createLoginLink($id, $params = null, $opts = null)
320 {
321 return self::_createNestedResource($id, static::PATH_LOGIN_LINKS, $params, $opts);
322 }
323 const PATH_PERSONS = '/persons';
324
325 /**
326 * @param string $id the ID of the account on which to retrieve the persons
327 * @param null|array $params
328 * @param null|array|string $opts
329 *
330 * @throws \Stripe\Exception\ApiErrorException if the request fails
331 *
332 * @return \Stripe\Collection<\Stripe\Person> the list of persons
333 */
334 public static function allPersons($id, $params = null, $opts = null)
335 {
336 return self::_allNestedResources($id, static::PATH_PERSONS, $params, $opts);
337 }
338
339 /**
340 * @param string $id the ID of the account on which to create the person
341 * @param null|array $params
342 * @param null|array|string $opts
343 *
344 * @throws \Stripe\Exception\ApiErrorException if the request fails
345 *
346 * @return \Stripe\Person
347 */
348 public static function createPerson($id, $params = null, $opts = null)
349 {
350 return self::_createNestedResource($id, static::PATH_PERSONS, $params, $opts);
351 }
352
353 /**
354 * @param string $id the ID of the account to which the person belongs
355 * @param string $personId the ID of the person to delete
356 * @param null|array $params
357 * @param null|array|string $opts
358 *
359 * @throws \Stripe\Exception\ApiErrorException if the request fails
360 *
361 * @return \Stripe\Person
362 */
363 public static function deletePerson($id, $personId, $params = null, $opts = null)
364 {
365 return self::_deleteNestedResource($id, static::PATH_PERSONS, $personId, $params, $opts);
366 }
367
368 /**
369 * @param string $id the ID of the account to which the person belongs
370 * @param string $personId the ID of the person to retrieve
371 * @param null|array $params
372 * @param null|array|string $opts
373 *
374 * @throws \Stripe\Exception\ApiErrorException if the request fails
375 *
376 * @return \Stripe\Person
377 */
378 public static function retrievePerson($id, $personId, $params = null, $opts = null)
379 {
380 return self::_retrieveNestedResource($id, static::PATH_PERSONS, $personId, $params, $opts);
381 }
382
383 /**
384 * @param string $id the ID of the account to which the person belongs
385 * @param string $personId the ID of the person to update
386 * @param null|array $params
387 * @param null|array|string $opts
388 *
389 * @throws \Stripe\Exception\ApiErrorException if the request fails
390 *
391 * @return \Stripe\Person
392 */
393 public static function updatePerson($id, $personId, $params = null, $opts = null)
394 {
395 return self::_updateNestedResource($id, static::PATH_PERSONS, $personId, $params, $opts);
396 }
397 }
398