• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stripe / stripe-php / #7087

pending completion
#7087

push

php-coveralls

pakrym-stripe
Bump version to 10.14.0-beta.2

1831 of 2732 relevant lines covered (67.02%)

3.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.97
/lib/Account.php
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 requirements or if the account is
10
 * enabled to make live charges or receive payouts.
11
 *
12
 * For Custom accounts, the properties below are always returned. For other accounts, some properties are returned until that
13
 * account has started to go through Connect Onboarding. Once you create an <a href="https://stripe.com/docs/api/account_links">Account Link</a>
14
 * for a Standard or Express account, some parameters are no longer returned. These are marked as <strong>Custom Only</strong> or <strong>Custom and Express</strong>
15
 * below. Learn about the differences <a href="https://stripe.com/docs/connect/accounts">between accounts</a>.
16
 *
17
 * @property string $id Unique identifier for the object.
18
 * @property string $object String representing the object's type. Objects of the same type share the same value.
19
 * @property null|\Stripe\StripeObject $business_profile Business information about the account.
20
 * @property null|string $business_type The business type.
21
 * @property null|\Stripe\StripeObject $capabilities
22
 * @property null|bool $charges_enabled Whether the account can create live charges.
23
 * @property null|\Stripe\StripeObject $company
24
 * @property null|\Stripe\StripeObject $controller
25
 * @property null|string $country The account's country.
26
 * @property null|int $created Time at which the account was connected. Measured in seconds since the Unix epoch.
27
 * @property null|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>.
28
 * @property null|bool $details_submitted Whether account details have been submitted. Standard accounts cannot receive payouts before this is true.
29
 * @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.
30
 * @property null|\Stripe\Collection<\Stripe\BankAccount|\Stripe\Card> $external_accounts External accounts (bank accounts and debit cards) currently attached to this account
31
 * @property null|\Stripe\StripeObject $future_requirements
32
 * @property null|\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>
33
 * @property null|\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.
34
 * @property null|bool $payouts_enabled Whether Stripe can send payouts to this account.
35
 * @property null|\Stripe\StripeObject $requirements
36
 * @property null|\Stripe\StripeObject $settings Options for customizing how the account functions within Stripe.
37
 * @property null|\Stripe\StripeObject $tos_acceptance
38
 * @property null|string $type The Stripe account type. Can be <code>standard</code>, <code>express</code>, or <code>custom</code>.
39
 */
40
class Account extends ApiResource
41
{
42
    const OBJECT_NAME = 'account';
43

44
    use ApiOperations\All;
45
    use ApiOperations\Create;
46
    use ApiOperations\Delete;
47
    use ApiOperations\NestedResource;
48
    use ApiOperations\Update;
49

50
    const BUSINESS_TYPE_COMPANY = 'company';
51
    const BUSINESS_TYPE_GOVERNMENT_ENTITY = 'government_entity';
52
    const BUSINESS_TYPE_INDIVIDUAL = 'individual';
53
    const BUSINESS_TYPE_NON_PROFIT = 'non_profit';
54

55
    const TYPE_CUSTOM = 'custom';
56
    const TYPE_EXPRESS = 'express';
57
    const TYPE_STANDARD = 'standard';
58

59
    use ApiOperations\Retrieve {
60
        retrieve as protected _retrieve;
61
    }
62

63
    public static function getSavedNestedResources()
64
    {
65
        static $savedNestedResources = null;
7✔
66
        if (null === $savedNestedResources) {
7✔
67
            $savedNestedResources = new Util\Set([
1✔
68
                'external_account',
1✔
69
                'bank_account',
1✔
70
            ]);
1✔
71
        }
72

73
        return $savedNestedResources;
7✔
74
    }
75

76
    public function instanceUrl()
77
    {
78
        if (null === $this['id']) {
7✔
79
            return '/v1/account';
1✔
80
        }
81

82
        return parent::instanceUrl();
6✔
83
    }
84

85
    /**
86
     * @param null|array|string $id the ID of the account to retrieve, or an
87
     *     options array containing an `id` key
88
     * @param null|array|string $opts
89
     *
90
     * @throws \Stripe\Exception\ApiErrorException if the request fails
91
     *
92
     * @return \Stripe\Account
93
     */
94
    public static function retrieve($id = null, $opts = null)
95
    {
96
        if (!$opts && \is_string($id) && 'sk_' === \substr($id, 0, 3)) {
7✔
97
            $opts = $id;
×
98
            $id = null;
×
99
        }
100

101
        return self::_retrieve($id, $opts);
7✔
102
    }
103

104
    public function serializeParameters($force = false)
105
    {
106
        $update = parent::serializeParameters($force);
15✔
107
        if (isset($this->_values['legal_entity'])) {
15✔
108
            $entity = $this['legal_entity'];
6✔
109
            if (isset($entity->_values['additional_owners'])) {
6✔
110
                $owners = $entity['additional_owners'];
5✔
111
                $entityUpdate = isset($update['legal_entity']) ? $update['legal_entity'] : [];
5✔
112
                $entityUpdate['additional_owners'] = $this->serializeAdditionalOwners($entity, $owners);
5✔
113
                $update['legal_entity'] = $entityUpdate;
4✔
114
            }
115
        }
116
        if (isset($this->_values['individual'])) {
14✔
117
            $individual = $this['individual'];
3✔
118
            if (($individual instanceof Person) && !isset($update['individual'])) {
3✔
119
                $update['individual'] = $individual->serializeParameters($force);
1✔
120
            }
121
        }
122

123
        return $update;
14✔
124
    }
125

126
    private function serializeAdditionalOwners($legalEntity, $additionalOwners)
127
    {
128
        if (isset($legalEntity->_originalValues['additional_owners'])) {
5✔
129
            $originalValue = $legalEntity->_originalValues['additional_owners'];
4✔
130
        } else {
131
            $originalValue = [];
1✔
132
        }
133
        if (($originalValue) && (\count($originalValue) > \count($additionalOwners))) {
5✔
134
            throw new Exception\InvalidArgumentException(
1✔
135
                'You cannot delete an item from an array, you must instead set a new array'
1✔
136
            );
1✔
137
        }
138

139
        $updateArr = [];
4✔
140
        foreach ($additionalOwners as $i => $v) {
4✔
141
            $update = ($v instanceof StripeObject) ? $v->serializeParameters() : $v;
4✔
142

143
            if ([] !== $update) {
4✔
144
                if (!$originalValue
3✔
145
                    || !\array_key_exists($i, $originalValue)
2✔
146
                    || ($update !== $legalEntity->serializeParamsValue($originalValue[$i], null, false, true))) {
3✔
147
                    $updateArr[$i] = $update;
3✔
148
                }
149
            }
150
        }
151

152
        return $updateArr;
4✔
153
    }
154

155
    /**
156
     * @param null|array $clientId
157
     * @param null|array|string $opts
158
     *
159
     * @throws \Stripe\Exception\ApiErrorException if the request fails
160
     *
161
     * @return \Stripe\StripeObject object containing the response from the API
162
     */
163
    public function deauthorize($clientId = null, $opts = null)
164
    {
165
        $params = [
1✔
166
            'client_id' => $clientId,
1✔
167
            'stripe_user_id' => $this->id,
1✔
168
        ];
1✔
169

170
        return OAuth::deauthorize($params, $opts);
1✔
171
    }
172

173
    /**
174
     * @param null|array $params
175
     * @param null|array|string $opts
176
     *
177
     * @throws \Stripe\Exception\ApiErrorException if the request fails
178
     *
179
     * @return \Stripe\Account the rejected account
180
     */
181
    public function reject($params = null, $opts = null)
182
    {
183
        $url = $this->instanceUrl() . '/reject';
1✔
184
        list($response, $opts) = $this->_request('post', $url, $params, $opts);
1✔
185
        $this->refreshFrom($response, $opts);
1✔
186

187
        return $this;
1✔
188
    }
189

190
    const PATH_CAPABILITIES = '/capabilities';
191

192
    /**
193
     * @param string $id the ID of the account on which to retrieve the capabilities
194
     * @param null|array $params
195
     * @param null|array|string $opts
196
     *
197
     * @throws \Stripe\Exception\ApiErrorException if the request fails
198
     *
199
     * @return \Stripe\Collection<\Stripe\Capability> the list of capabilities
200
     */
201
    public static function allCapabilities($id, $params = null, $opts = null)
202
    {
203
        return self::_allNestedResources($id, static::PATH_CAPABILITIES, $params, $opts);
1✔
204
    }
205

206
    /**
207
     * @param string $id the ID of the account to which the capability belongs
208
     * @param string $capabilityId the ID of the capability to retrieve
209
     * @param null|array $params
210
     * @param null|array|string $opts
211
     *
212
     * @throws \Stripe\Exception\ApiErrorException if the request fails
213
     *
214
     * @return \Stripe\Capability
215
     */
216
    public static function retrieveCapability($id, $capabilityId, $params = null, $opts = null)
217
    {
218
        return self::_retrieveNestedResource($id, static::PATH_CAPABILITIES, $capabilityId, $params, $opts);
1✔
219
    }
220

221
    /**
222
     * @param string $id the ID of the account to which the capability belongs
223
     * @param string $capabilityId the ID of the capability to update
224
     * @param null|array $params
225
     * @param null|array|string $opts
226
     *
227
     * @throws \Stripe\Exception\ApiErrorException if the request fails
228
     *
229
     * @return \Stripe\Capability
230
     */
231
    public static function updateCapability($id, $capabilityId, $params = null, $opts = null)
232
    {
233
        return self::_updateNestedResource($id, static::PATH_CAPABILITIES, $capabilityId, $params, $opts);
1✔
234
    }
235
    const PATH_EXTERNAL_ACCOUNTS = '/external_accounts';
236

237
    /**
238
     * @param string $id the ID of the account on which to retrieve the external accounts
239
     * @param null|array $params
240
     * @param null|array|string $opts
241
     *
242
     * @throws \Stripe\Exception\ApiErrorException if the request fails
243
     *
244
     * @return \Stripe\Collection<\Stripe\BankAccount|\Stripe\Card> the list of external accounts (BankAccount or Card)
245
     */
246
    public static function allExternalAccounts($id, $params = null, $opts = null)
247
    {
248
        return self::_allNestedResources($id, static::PATH_EXTERNAL_ACCOUNTS, $params, $opts);
1✔
249
    }
250

251
    /**
252
     * @param string $id the ID of the account on which to create the external account
253
     * @param null|array $params
254
     * @param null|array|string $opts
255
     *
256
     * @throws \Stripe\Exception\ApiErrorException if the request fails
257
     *
258
     * @return \Stripe\BankAccount|\Stripe\Card
259
     */
260
    public static function createExternalAccount($id, $params = null, $opts = null)
261
    {
262
        return self::_createNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $params, $opts);
1✔
263
    }
264

265
    /**
266
     * @param string $id the ID of the account to which the external account belongs
267
     * @param string $externalAccountId the ID of the external account to delete
268
     * @param null|array $params
269
     * @param null|array|string $opts
270
     *
271
     * @throws \Stripe\Exception\ApiErrorException if the request fails
272
     *
273
     * @return \Stripe\BankAccount|\Stripe\Card
274
     */
275
    public static function deleteExternalAccount($id, $externalAccountId, $params = null, $opts = null)
276
    {
277
        return self::_deleteNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $opts);
1✔
278
    }
279

280
    /**
281
     * @param string $id the ID of the account to which the external account belongs
282
     * @param string $externalAccountId the ID of the external account to retrieve
283
     * @param null|array $params
284
     * @param null|array|string $opts
285
     *
286
     * @throws \Stripe\Exception\ApiErrorException if the request fails
287
     *
288
     * @return \Stripe\BankAccount|\Stripe\Card
289
     */
290
    public static function retrieveExternalAccount($id, $externalAccountId, $params = null, $opts = null)
291
    {
292
        return self::_retrieveNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $opts);
1✔
293
    }
294

295
    /**
296
     * @param string $id the ID of the account to which the external account belongs
297
     * @param string $externalAccountId the ID of the external account to update
298
     * @param null|array $params
299
     * @param null|array|string $opts
300
     *
301
     * @throws \Stripe\Exception\ApiErrorException if the request fails
302
     *
303
     * @return \Stripe\BankAccount|\Stripe\Card
304
     */
305
    public static function updateExternalAccount($id, $externalAccountId, $params = null, $opts = null)
306
    {
307
        return self::_updateNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $opts);
1✔
308
    }
309
    const PATH_LOGIN_LINKS = '/login_links';
310

311
    /**
312
     * @param string $id the ID of the account on which to create the login link
313
     * @param null|array $params
314
     * @param null|array|string $opts
315
     *
316
     * @throws \Stripe\Exception\ApiErrorException if the request fails
317
     *
318
     * @return \Stripe\LoginLink
319
     */
320
    public static function createLoginLink($id, $params = null, $opts = null)
321
    {
322
        return self::_createNestedResource($id, static::PATH_LOGIN_LINKS, $params, $opts);
1✔
323
    }
324
    const PATH_PERSONS = '/persons';
325

326
    /**
327
     * @param string $id the ID of the account on which to retrieve the persons
328
     * @param null|array $params
329
     * @param null|array|string $opts
330
     *
331
     * @throws \Stripe\Exception\ApiErrorException if the request fails
332
     *
333
     * @return \Stripe\Collection<\Stripe\Person> the list of persons
334
     */
335
    public static function allPersons($id, $params = null, $opts = null)
336
    {
337
        return self::_allNestedResources($id, static::PATH_PERSONS, $params, $opts);
2✔
338
    }
339

340
    /**
341
     * @param string $id the ID of the account on which to create the person
342
     * @param null|array $params
343
     * @param null|array|string $opts
344
     *
345
     * @throws \Stripe\Exception\ApiErrorException if the request fails
346
     *
347
     * @return \Stripe\Person
348
     */
349
    public static function createPerson($id, $params = null, $opts = null)
350
    {
351
        return self::_createNestedResource($id, static::PATH_PERSONS, $params, $opts);
1✔
352
    }
353

354
    /**
355
     * @param string $id the ID of the account to which the person belongs
356
     * @param string $personId the ID of the person to delete
357
     * @param null|array $params
358
     * @param null|array|string $opts
359
     *
360
     * @throws \Stripe\Exception\ApiErrorException if the request fails
361
     *
362
     * @return \Stripe\Person
363
     */
364
    public static function deletePerson($id, $personId, $params = null, $opts = null)
365
    {
366
        return self::_deleteNestedResource($id, static::PATH_PERSONS, $personId, $params, $opts);
1✔
367
    }
368

369
    /**
370
     * @param string $id the ID of the account to which the person belongs
371
     * @param string $personId the ID of the person to retrieve
372
     * @param null|array $params
373
     * @param null|array|string $opts
374
     *
375
     * @throws \Stripe\Exception\ApiErrorException if the request fails
376
     *
377
     * @return \Stripe\Person
378
     */
379
    public static function retrievePerson($id, $personId, $params = null, $opts = null)
380
    {
381
        return self::_retrieveNestedResource($id, static::PATH_PERSONS, $personId, $params, $opts);
1✔
382
    }
383

384
    /**
385
     * @param string $id the ID of the account to which the person belongs
386
     * @param string $personId the ID of the person to update
387
     * @param null|array $params
388
     * @param null|array|string $opts
389
     *
390
     * @throws \Stripe\Exception\ApiErrorException if the request fails
391
     *
392
     * @return \Stripe\Person
393
     */
394
    public static function updatePerson($id, $personId, $params = null, $opts = null)
395
    {
396
        return self::_updateNestedResource($id, static::PATH_PERSONS, $personId, $params, $opts);
1✔
397
    }
398
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc