Account.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\FinancialConnections;
  4. /**
  5. * A Financial Connections Account represents an account that exists outside of Stripe, to which you have been granted some degree of access.
  6. *
  7. * @property string $id Unique identifier for the object.
  8. * @property string $object String representing the object's type. Objects of the same type share the same value.
  9. * @property null|\Stripe\StripeObject $account_holder The account holder that this account belongs to.
  10. * @property null|\Stripe\StripeObject $balance The most recent information about the account's balance.
  11. * @property null|\Stripe\StripeObject $balance_refresh The state of the most recent attempt to refresh the account balance.
  12. * @property string $category The type of the account. Account category is further divided in <code>subcategory</code>.
  13. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  14. * @property null|string $display_name A human-readable name that has been assigned to this account, either by the account holder or by the institution.
  15. * @property string $institution_name The name of the institution that holds this account.
  16. * @property null|string $last4 The last 4 digits of the account number. If present, this will be 4 numeric characters.
  17. * @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
  18. * @property null|string|\Stripe\FinancialConnections\AccountOwnership $ownership The most recent information about the account's owners.
  19. * @property null|\Stripe\StripeObject $ownership_refresh The state of the most recent attempt to refresh the account owners.
  20. * @property null|string[] $permissions The list of permissions granted by this account.
  21. * @property string $status The status of the link to the account.
  22. * @property string $subcategory <p>If <code>category</code> is <code>cash</code>, one of:</p><p>- <code>checking</code> - <code>savings</code> - <code>other</code></p><p>If <code>category</code> is <code>credit</code>, one of:</p><p>- <code>mortgage</code> - <code>line_of_credit</code> - <code>credit_card</code> - <code>other</code></p><p>If <code>category</code> is <code>investment</code> or <code>other</code>, this will be <code>other</code>.</p>
  23. * @property null|string[] $subscriptions The list of data refresh subscriptions requested on this account.
  24. * @property string[] $supported_payment_method_types The <a href="https://stripe.com/docs/api/payment_methods/object#payment_method_object-type">PaymentMethod type</a>(s) that can be created from this account.
  25. * @property null|\Stripe\StripeObject $transaction_refresh The state of the most recent attempt to refresh the account transactions.
  26. */
  27. class Account extends \Stripe\ApiResource
  28. {
  29. const OBJECT_NAME = 'financial_connections.account';
  30. const CATEGORY_CASH = 'cash';
  31. const CATEGORY_CREDIT = 'credit';
  32. const CATEGORY_INVESTMENT = 'investment';
  33. const CATEGORY_OTHER = 'other';
  34. const STATUS_ACTIVE = 'active';
  35. const STATUS_DISCONNECTED = 'disconnected';
  36. const STATUS_INACTIVE = 'inactive';
  37. const SUBCATEGORY_CHECKING = 'checking';
  38. const SUBCATEGORY_CREDIT_CARD = 'credit_card';
  39. const SUBCATEGORY_LINE_OF_CREDIT = 'line_of_credit';
  40. const SUBCATEGORY_MORTGAGE = 'mortgage';
  41. const SUBCATEGORY_OTHER = 'other';
  42. const SUBCATEGORY_SAVINGS = 'savings';
  43. /**
  44. * Returns a list of Financial Connections <code>Account</code> objects.
  45. *
  46. * @param null|array $params
  47. * @param null|array|string $opts
  48. *
  49. * @throws \Stripe\Exception\ApiErrorException if the request fails
  50. *
  51. * @return \Stripe\Collection<\Stripe\FinancialConnections\Account> of ApiResources
  52. */
  53. public static function all($params = null, $opts = null)
  54. {
  55. $url = static::classUrl();
  56. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  57. }
  58. /**
  59. * Retrieves the details of an Financial Connections <code>Account</code>.
  60. *
  61. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  62. * @param null|array|string $opts
  63. *
  64. * @throws \Stripe\Exception\ApiErrorException if the request fails
  65. *
  66. * @return \Stripe\FinancialConnections\Account
  67. */
  68. public static function retrieve($id, $opts = null)
  69. {
  70. $opts = \Stripe\Util\RequestOptions::parse($opts);
  71. $instance = new static($id, $opts);
  72. $instance->refresh();
  73. return $instance;
  74. }
  75. /**
  76. * @param null|array $params
  77. * @param null|array|string $opts
  78. *
  79. * @throws \Stripe\Exception\ApiErrorException if the request fails
  80. *
  81. * @return \Stripe\FinancialConnections\Account the disconnected account
  82. */
  83. public function disconnect($params = null, $opts = null)
  84. {
  85. $url = $this->instanceUrl() . '/disconnect';
  86. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  87. $this->refreshFrom($response, $opts);
  88. return $this;
  89. }
  90. /**
  91. * @param string $id
  92. * @param null|array $params
  93. * @param null|array|string $opts
  94. *
  95. * @throws \Stripe\Exception\ApiErrorException if the request fails
  96. *
  97. * @return \Stripe\Collection<\Stripe\FinancialConnections\AccountOwner> list of account owners
  98. */
  99. public static function allOwners($id, $params = null, $opts = null)
  100. {
  101. $url = static::resourceUrl($id) . '/owners';
  102. list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
  103. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  104. $obj->setLastResponse($response);
  105. return $obj;
  106. }
  107. /**
  108. * @param null|array $params
  109. * @param null|array|string $opts
  110. *
  111. * @throws \Stripe\Exception\ApiErrorException if the request fails
  112. *
  113. * @return \Stripe\FinancialConnections\Account the refreshed account
  114. */
  115. public function refreshAccount($params = null, $opts = null)
  116. {
  117. $url = $this->instanceUrl() . '/refresh';
  118. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  119. $this->refreshFrom($response, $opts);
  120. return $this;
  121. }
  122. /**
  123. * @param null|array $params
  124. * @param null|array|string $opts
  125. *
  126. * @throws \Stripe\Exception\ApiErrorException if the request fails
  127. *
  128. * @return \Stripe\FinancialConnections\Account the subscribed account
  129. */
  130. public function subscribe($params = null, $opts = null)
  131. {
  132. $url = $this->instanceUrl() . '/subscribe';
  133. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  134. $this->refreshFrom($response, $opts);
  135. return $this;
  136. }
  137. /**
  138. * @param null|array $params
  139. * @param null|array|string $opts
  140. *
  141. * @throws \Stripe\Exception\ApiErrorException if the request fails
  142. *
  143. * @return \Stripe\FinancialConnections\Account the unsubscribed account
  144. */
  145. public function unsubscribe($params = null, $opts = null)
  146. {
  147. $url = $this->instanceUrl() . '/unsubscribe';
  148. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  149. $this->refreshFrom($response, $opts);
  150. return $this;
  151. }
  152. }