AccountService.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Service;
  4. /**
  5. * @phpstan-import-type RequestOptionsArray from \Stripe\Util\RequestOptions
  6. * @psalm-import-type RequestOptionsArray from \Stripe\Util\RequestOptions
  7. */
  8. class AccountService extends \Stripe\Service\AbstractService
  9. {
  10. /**
  11. * Returns a list of accounts connected to your platform via <a
  12. * href="/docs/connect">Connect</a>. If you’re not a platform, the list is empty.
  13. *
  14. * @param null|array $params
  15. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  16. *
  17. * @throws \Stripe\Exception\ApiErrorException if the request fails
  18. *
  19. * @return \Stripe\Collection<\Stripe\Account>
  20. */
  21. public function all($params = null, $opts = null)
  22. {
  23. return $this->requestCollection('get', '/v1/accounts', $params, $opts);
  24. }
  25. /**
  26. * Returns a list of capabilities associated with the account. The capabilities are
  27. * returned sorted by creation date, with the most recent capability appearing
  28. * first.
  29. *
  30. * @param string $parentId
  31. * @param null|array $params
  32. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  33. *
  34. * @throws \Stripe\Exception\ApiErrorException if the request fails
  35. *
  36. * @return \Stripe\Collection<\Stripe\Capability>
  37. */
  38. public function allCapabilities($parentId, $params = null, $opts = null)
  39. {
  40. return $this->requestCollection('get', $this->buildPath('/v1/accounts/%s/capabilities', $parentId), $params, $opts);
  41. }
  42. /**
  43. * List external accounts for an account.
  44. *
  45. * @param string $parentId
  46. * @param null|array $params
  47. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  48. *
  49. * @throws \Stripe\Exception\ApiErrorException if the request fails
  50. *
  51. * @return \Stripe\Collection<\Stripe\BankAccount|\Stripe\Card>
  52. */
  53. public function allExternalAccounts($parentId, $params = null, $opts = null)
  54. {
  55. return $this->requestCollection('get', $this->buildPath('/v1/accounts/%s/external_accounts', $parentId), $params, $opts);
  56. }
  57. /**
  58. * Returns a list of people associated with the account’s legal entity. The people
  59. * are returned sorted by creation date, with the most recent people appearing
  60. * first.
  61. *
  62. * @param string $parentId
  63. * @param null|array $params
  64. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  65. *
  66. * @throws \Stripe\Exception\ApiErrorException if the request fails
  67. *
  68. * @return \Stripe\Collection<\Stripe\Person>
  69. */
  70. public function allPersons($parentId, $params = null, $opts = null)
  71. {
  72. return $this->requestCollection('get', $this->buildPath('/v1/accounts/%s/persons', $parentId), $params, $opts);
  73. }
  74. /**
  75. * With <a href="/docs/connect">Connect</a>, you can create Stripe accounts for
  76. * your users. To do this, you’ll first need to <a
  77. * href="https://dashboard.stripe.com/account/applications/settings">register your
  78. * platform</a>.
  79. *
  80. * If you’ve already collected information for your connected accounts, you <a
  81. * href="/docs/connect/best-practices#onboarding">can prefill that information</a>
  82. * when creating the account. Connect Onboarding won’t ask for the prefilled
  83. * information during account onboarding. You can prefill any information on the
  84. * account.
  85. *
  86. * @param null|array $params
  87. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  88. *
  89. * @throws \Stripe\Exception\ApiErrorException if the request fails
  90. *
  91. * @return \Stripe\Account
  92. */
  93. public function create($params = null, $opts = null)
  94. {
  95. return $this->request('post', '/v1/accounts', $params, $opts);
  96. }
  97. /**
  98. * Create an external account for a given account.
  99. *
  100. * @param string $parentId
  101. * @param null|array $params
  102. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  103. *
  104. * @throws \Stripe\Exception\ApiErrorException if the request fails
  105. *
  106. * @return \Stripe\BankAccount|\Stripe\Card
  107. */
  108. public function createExternalAccount($parentId, $params = null, $opts = null)
  109. {
  110. return $this->request('post', $this->buildPath('/v1/accounts/%s/external_accounts', $parentId), $params, $opts);
  111. }
  112. /**
  113. * Creates a single-use login link for a connected account to access the Express
  114. * Dashboard.
  115. *
  116. * <strong>You can only create login links for accounts that use the <a
  117. * href="/connect/express-dashboard">Express Dashboard</a> and are connected to
  118. * your platform</strong>.
  119. *
  120. * @param string $parentId
  121. * @param null|array $params
  122. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  123. *
  124. * @throws \Stripe\Exception\ApiErrorException if the request fails
  125. *
  126. * @return \Stripe\LoginLink
  127. */
  128. public function createLoginLink($parentId, $params = null, $opts = null)
  129. {
  130. return $this->request('post', $this->buildPath('/v1/accounts/%s/login_links', $parentId), $params, $opts);
  131. }
  132. /**
  133. * Creates a new person.
  134. *
  135. * @param string $parentId
  136. * @param null|array $params
  137. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  138. *
  139. * @throws \Stripe\Exception\ApiErrorException if the request fails
  140. *
  141. * @return \Stripe\Person
  142. */
  143. public function createPerson($parentId, $params = null, $opts = null)
  144. {
  145. return $this->request('post', $this->buildPath('/v1/accounts/%s/persons', $parentId), $params, $opts);
  146. }
  147. /**
  148. * With <a href="/connect">Connect</a>, you can delete accounts you manage.
  149. *
  150. * Test-mode accounts can be deleted at any time.
  151. *
  152. * Live-mode accounts where Stripe is responsible for negative account balances
  153. * cannot be deleted, which includes Standard accounts. Live-mode accounts where
  154. * your platform is liable for negative account balances, which includes Custom and
  155. * Express accounts, can be deleted when all <a
  156. * href="/api/balance/balanace_object">balances</a> are zero.
  157. *
  158. * If you want to delete your own account, use the <a
  159. * href="https://dashboard.stripe.com/settings/account">account information tab in
  160. * your account settings</a> instead.
  161. *
  162. * @param string $id
  163. * @param null|array $params
  164. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  165. *
  166. * @throws \Stripe\Exception\ApiErrorException if the request fails
  167. *
  168. * @return \Stripe\Account
  169. */
  170. public function delete($id, $params = null, $opts = null)
  171. {
  172. return $this->request('delete', $this->buildPath('/v1/accounts/%s', $id), $params, $opts);
  173. }
  174. /**
  175. * Delete a specified external account for a given account.
  176. *
  177. * @param string $parentId
  178. * @param string $id
  179. * @param null|array $params
  180. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  181. *
  182. * @throws \Stripe\Exception\ApiErrorException if the request fails
  183. *
  184. * @return \Stripe\BankAccount|\Stripe\Card
  185. */
  186. public function deleteExternalAccount($parentId, $id, $params = null, $opts = null)
  187. {
  188. return $this->request('delete', $this->buildPath('/v1/accounts/%s/external_accounts/%s', $parentId, $id), $params, $opts);
  189. }
  190. /**
  191. * Deletes an existing person’s relationship to the account’s legal entity. Any
  192. * person with a relationship for an account can be deleted through the API, except
  193. * if the person is the <code>account_opener</code>. If your integration is using
  194. * the <code>executive</code> parameter, you cannot delete the only verified
  195. * <code>executive</code> on file.
  196. *
  197. * @param string $parentId
  198. * @param string $id
  199. * @param null|array $params
  200. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  201. *
  202. * @throws \Stripe\Exception\ApiErrorException if the request fails
  203. *
  204. * @return \Stripe\Person
  205. */
  206. public function deletePerson($parentId, $id, $params = null, $opts = null)
  207. {
  208. return $this->request('delete', $this->buildPath('/v1/accounts/%s/persons/%s', $parentId, $id), $params, $opts);
  209. }
  210. /**
  211. * With <a href="/connect">Connect</a>, you can reject accounts that you have
  212. * flagged as suspicious.
  213. *
  214. * Only accounts where your platform is liable for negative account balances, which
  215. * includes Custom and Express accounts, can be rejected. Test-mode accounts can be
  216. * rejected at any time. Live-mode accounts can only be rejected after all balances
  217. * are zero.
  218. *
  219. * @param string $id
  220. * @param null|array $params
  221. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  222. *
  223. * @throws \Stripe\Exception\ApiErrorException if the request fails
  224. *
  225. * @return \Stripe\Account
  226. */
  227. public function reject($id, $params = null, $opts = null)
  228. {
  229. return $this->request('post', $this->buildPath('/v1/accounts/%s/reject', $id), $params, $opts);
  230. }
  231. /**
  232. * Retrieves information about the specified Account Capability.
  233. *
  234. * @param string $parentId
  235. * @param string $id
  236. * @param null|array $params
  237. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  238. *
  239. * @throws \Stripe\Exception\ApiErrorException if the request fails
  240. *
  241. * @return \Stripe\Capability
  242. */
  243. public function retrieveCapability($parentId, $id, $params = null, $opts = null)
  244. {
  245. return $this->request('get', $this->buildPath('/v1/accounts/%s/capabilities/%s', $parentId, $id), $params, $opts);
  246. }
  247. /**
  248. * Retrieve a specified external account for a given account.
  249. *
  250. * @param string $parentId
  251. * @param string $id
  252. * @param null|array $params
  253. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  254. *
  255. * @throws \Stripe\Exception\ApiErrorException if the request fails
  256. *
  257. * @return \Stripe\BankAccount|\Stripe\Card
  258. */
  259. public function retrieveExternalAccount($parentId, $id, $params = null, $opts = null)
  260. {
  261. return $this->request('get', $this->buildPath('/v1/accounts/%s/external_accounts/%s', $parentId, $id), $params, $opts);
  262. }
  263. /**
  264. * Retrieves an existing person.
  265. *
  266. * @param string $parentId
  267. * @param string $id
  268. * @param null|array $params
  269. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  270. *
  271. * @throws \Stripe\Exception\ApiErrorException if the request fails
  272. *
  273. * @return \Stripe\Person
  274. */
  275. public function retrievePerson($parentId, $id, $params = null, $opts = null)
  276. {
  277. return $this->request('get', $this->buildPath('/v1/accounts/%s/persons/%s', $parentId, $id), $params, $opts);
  278. }
  279. /**
  280. * Updates a <a href="/connect/accounts">connected account</a> by setting the
  281. * values of the parameters passed. Any parameters not provided are left unchanged.
  282. *
  283. * For accounts where <a
  284. * href="/api/accounts/object#account_object-controller-requirement_collection">controller.requirement_collection</a>
  285. * is <code>application</code>, which includes Custom accounts, you can update any
  286. * information on the account.
  287. *
  288. * For accounts where <a
  289. * href="/api/accounts/object#account_object-controller-requirement_collection">controller.requirement_collection</a>
  290. * is <code>stripe</code>, which includes Standard and Express accounts, you can
  291. * update all information until you create an <a href="/api/account_links">Account
  292. * Link</a> or <a href="/api/account_sessions">Account Session</a> to start Connect
  293. * onboarding, after which some properties can no longer be updated.
  294. *
  295. * To update your own account, use the <a
  296. * href="https://dashboard.stripe.com/settings/account">Dashboard</a>. Refer to our
  297. * <a href="/docs/connect/updating-accounts">Connect</a> documentation to learn
  298. * more about updating accounts.
  299. *
  300. * @param string $id
  301. * @param null|array $params
  302. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  303. *
  304. * @throws \Stripe\Exception\ApiErrorException if the request fails
  305. *
  306. * @return \Stripe\Account
  307. */
  308. public function update($id, $params = null, $opts = null)
  309. {
  310. return $this->request('post', $this->buildPath('/v1/accounts/%s', $id), $params, $opts);
  311. }
  312. /**
  313. * Updates an existing Account Capability. Request or remove a capability by
  314. * updating its <code>requested</code> parameter.
  315. *
  316. * @param string $parentId
  317. * @param string $id
  318. * @param null|array $params
  319. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  320. *
  321. * @throws \Stripe\Exception\ApiErrorException if the request fails
  322. *
  323. * @return \Stripe\Capability
  324. */
  325. public function updateCapability($parentId, $id, $params = null, $opts = null)
  326. {
  327. return $this->request('post', $this->buildPath('/v1/accounts/%s/capabilities/%s', $parentId, $id), $params, $opts);
  328. }
  329. /**
  330. * Updates the metadata, account holder name, account holder type of a bank account
  331. * belonging to a connected account and optionally sets it as the default for its
  332. * currency. Other bank account details are not editable by design.
  333. *
  334. * You can only update bank accounts when <a
  335. * href="/api/accounts/object#account_object-controller-requirement_collection">account.controller.requirement_collection</a>
  336. * is <code>application</code>, which includes <a
  337. * href="/connect/custom-accounts">Custom accounts</a>.
  338. *
  339. * You can re-enable a disabled bank account by performing an update call without
  340. * providing any arguments or changes.
  341. *
  342. * @param string $parentId
  343. * @param string $id
  344. * @param null|array $params
  345. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  346. *
  347. * @throws \Stripe\Exception\ApiErrorException if the request fails
  348. *
  349. * @return \Stripe\BankAccount|\Stripe\Card
  350. */
  351. public function updateExternalAccount($parentId, $id, $params = null, $opts = null)
  352. {
  353. return $this->request('post', $this->buildPath('/v1/accounts/%s/external_accounts/%s', $parentId, $id), $params, $opts);
  354. }
  355. /**
  356. * Updates an existing person.
  357. *
  358. * @param string $parentId
  359. * @param string $id
  360. * @param null|array $params
  361. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  362. *
  363. * @throws \Stripe\Exception\ApiErrorException if the request fails
  364. *
  365. * @return \Stripe\Person
  366. */
  367. public function updatePerson($parentId, $id, $params = null, $opts = null)
  368. {
  369. return $this->request('post', $this->buildPath('/v1/accounts/%s/persons/%s', $parentId, $id), $params, $opts);
  370. }
  371. /**
  372. * Retrieves the details of an account.
  373. *
  374. * @param null|string $id
  375. * @param null|array $params
  376. * @param null|array|\Stripe\Util\RequestOptions $opts
  377. *
  378. * @throws \Stripe\Exception\ApiErrorException if the request fails
  379. *
  380. * @return \Stripe\Account
  381. */
  382. public function retrieve($id = null, $params = null, $opts = null)
  383. {
  384. if (null === $id) {
  385. return $this->request('get', '/v1/account', $params, $opts);
  386. }
  387. return $this->request('get', $this->buildPath('/v1/accounts/%s', $id), $params, $opts);
  388. }
  389. }