FinancialAccount.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Treasury;
  4. /**
  5. * Stripe Treasury provides users with a container for money called a FinancialAccount that is separate from their Payments balance.
  6. * FinancialAccounts serve as the source and destination of Treasury’s money movement APIs.
  7. *
  8. * @property string $id Unique identifier for the object.
  9. * @property string $object String representing the object's type. Objects of the same type share the same value.
  10. * @property null|string[] $active_features The array of paths to active Features in the Features hash.
  11. * @property \Stripe\StripeObject $balance Balance information for the FinancialAccount
  12. * @property string $country Two-letter country code (<a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO 3166-1 alpha-2</a>).
  13. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  14. * @property null|\Stripe\Treasury\FinancialAccountFeatures $features Encodes whether a FinancialAccount has access to a particular Feature, with a <code>status</code> enum and associated <code>status_details</code>. Stripe or the platform can control Features via the requested field.
  15. * @property \Stripe\StripeObject[] $financial_addresses The set of credentials that resolve to a FinancialAccount.
  16. * @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.
  17. * @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.
  18. * @property null|string[] $pending_features The array of paths to pending Features in the Features hash.
  19. * @property null|\Stripe\StripeObject $platform_restrictions The set of functionalities that the platform can restrict on the FinancialAccount.
  20. * @property null|string[] $restricted_features The array of paths to restricted Features in the Features hash.
  21. * @property string $status The enum specifying what state the account is in.
  22. * @property \Stripe\StripeObject $status_details
  23. * @property string[] $supported_currencies The currencies the FinancialAccount can hold a balance in. Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase.
  24. */
  25. class FinancialAccount extends \Stripe\ApiResource
  26. {
  27. const OBJECT_NAME = 'treasury.financial_account';
  28. use \Stripe\ApiOperations\Update;
  29. const STATUS_CLOSED = 'closed';
  30. const STATUS_OPEN = 'open';
  31. /**
  32. * Creates a new FinancialAccount. For now, each connected account can only have
  33. * one FinancialAccount.
  34. *
  35. * @param null|array $params
  36. * @param null|array|string $options
  37. *
  38. * @throws \Stripe\Exception\ApiErrorException if the request fails
  39. *
  40. * @return \Stripe\Treasury\FinancialAccount the created resource
  41. */
  42. public static function create($params = null, $options = null)
  43. {
  44. self::_validateParams($params);
  45. $url = static::classUrl();
  46. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  47. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  48. $obj->setLastResponse($response);
  49. return $obj;
  50. }
  51. /**
  52. * Returns a list of FinancialAccounts.
  53. *
  54. * @param null|array $params
  55. * @param null|array|string $opts
  56. *
  57. * @throws \Stripe\Exception\ApiErrorException if the request fails
  58. *
  59. * @return \Stripe\Collection<\Stripe\Treasury\FinancialAccount> of ApiResources
  60. */
  61. public static function all($params = null, $opts = null)
  62. {
  63. $url = static::classUrl();
  64. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  65. }
  66. /**
  67. * Retrieves the details of a FinancialAccount.
  68. *
  69. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  70. * @param null|array|string $opts
  71. *
  72. * @throws \Stripe\Exception\ApiErrorException if the request fails
  73. *
  74. * @return \Stripe\Treasury\FinancialAccount
  75. */
  76. public static function retrieve($id, $opts = null)
  77. {
  78. $opts = \Stripe\Util\RequestOptions::parse($opts);
  79. $instance = new static($id, $opts);
  80. $instance->refresh();
  81. return $instance;
  82. }
  83. /**
  84. * Updates the details of a FinancialAccount.
  85. *
  86. * @param string $id the ID of the resource to update
  87. * @param null|array $params
  88. * @param null|array|string $opts
  89. *
  90. * @throws \Stripe\Exception\ApiErrorException if the request fails
  91. *
  92. * @return \Stripe\Treasury\FinancialAccount the updated resource
  93. */
  94. public static function update($id, $params = null, $opts = null)
  95. {
  96. self::_validateParams($params);
  97. $url = static::resourceUrl($id);
  98. list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
  99. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  100. $obj->setLastResponse($response);
  101. return $obj;
  102. }
  103. /**
  104. * @param null|array $params
  105. * @param null|array|string $opts
  106. *
  107. * @throws \Stripe\Exception\ApiErrorException if the request fails
  108. *
  109. * @return \Stripe\Treasury\FinancialAccountFeatures the retrieved financial account features
  110. */
  111. public function retrieveFeatures($params = null, $opts = null)
  112. {
  113. $url = $this->instanceUrl() . '/features';
  114. list($response, $opts) = $this->_request('get', $url, $params, $opts);
  115. $obj = \Stripe\Util\Util::convertToStripeObject($response, $opts);
  116. $obj->setLastResponse($response);
  117. return $obj;
  118. }
  119. /**
  120. * @param null|array $params
  121. * @param null|array|string $opts
  122. *
  123. * @throws \Stripe\Exception\ApiErrorException if the request fails
  124. *
  125. * @return \Stripe\Treasury\FinancialAccountFeatures the updated financial account features
  126. */
  127. public function updateFeatures($params = null, $opts = null)
  128. {
  129. $url = $this->instanceUrl() . '/features';
  130. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  131. $this->refreshFrom($response, $opts);
  132. return $this;
  133. }
  134. }