Class: Stripe::Account
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::Account
- Extended by:
- Stripe::APIOperations::Create, Stripe::APIOperations::List, Stripe::APIOperations::NestedResource
- Defined in:
- lib/stripe/resources/account.rb
Overview
This is an object representing a Stripe account. You can retrieve it to see properties on the account like its current requirements or if the account is enabled to make live charges or receive payouts.
For Custom accounts, the properties below are always returned. For other accounts, some properties are returned until that account has started to go through Connect Onboarding. Once you create an [Account Link](stripe.com/docs/api/account_links) or [Account Session](stripe.com/docs/api/account_sessions), some properties are only returned for Custom accounts. Learn about the differences [between accounts](stripe.com/docs/connect/accounts).
Constant Summary collapse
- OBJECT_NAME =
"account"
Constants inherited from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary
Attributes inherited from APIResource
Class Method Summary collapse
-
.create(params = {}, opts = {}) ⇒ Object
With [Connect](stripe.com/docs/connect), you can create Stripe accounts for your users.
-
.delete(id, params = {}, opts = {}) ⇒ Object
With [Connect](stripe.com/docs/connect), you can delete accounts you manage.
-
.list(filters = {}, opts = {}) ⇒ Object
Returns a list of accounts connected to your platform via [Connect](stripe.com/docs/connect).
- .object_name ⇒ Object
-
.persons(account, params = {}, opts = {}) ⇒ Object
Returns a list of people associated with the account’s legal entity.
- .protected_fields ⇒ Object
-
.reject(account, params = {}, opts = {}) ⇒ Object
With [Connect](stripe.com/docs/connect), you may flag accounts as suspicious.
- .retrieve(id = nil, opts = {}) ⇒ Object
-
.update(id, params = {}, opts = {}) ⇒ Object
Updates a [connected account](stripe.com/docs/connect/accounts) by setting the values of the parameters passed.
Instance Method Summary collapse
- #deauthorize(client_id = nil, opts = {}) ⇒ Object
-
#delete(params = {}, opts = {}) ⇒ Object
With [Connect](stripe.com/docs/connect), you can delete accounts you manage.
- #legal_entity ⇒ Object
- #legal_entity=(_legal_entity) ⇒ Object
-
#persons(params = {}, opts = {}) ⇒ Object
Returns a list of people associated with the account’s legal entity.
-
#reject(params = {}, opts = {}) ⇒ Object
With [Connect](stripe.com/docs/connect), you may flag accounts as suspicious.
- #resource_url ⇒ Object
-
#serialize_params(options = {}) ⇒ Object
Somewhat unfortunately, we attempt to do a special encoding trick when serializing ‘additional_owners` under an account: when updating a value, we actually send the update parameters up as an integer-indexed hash rather than an array.
- #serialize_params_account(_obj, update_hash, options = {}) ⇒ Object
Methods included from Stripe::APIOperations::Create
Methods included from Stripe::APIOperations::List
Methods included from Stripe::APIOperations::NestedResource
Methods included from Stripe::APIOperations::Save
Methods included from Stripe::APIOperations::Delete
Methods inherited from APIResource
class_name, custom_method, #refresh, #request_stripe_object, resource_url, save_nested_resource
Methods included from Stripe::APIOperations::Request
Methods inherited from StripeObject
#==, #[], #[]=, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, #to_hash, #to_json, #to_s, #update_attributes, #values
Constructor Details
This class inherits a constructor from Stripe::StripeObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject
Class Method Details
.create(params = {}, opts = {}) ⇒ Object
With [Connect](stripe.com/docs/connect), you can create Stripe accounts for your users. To do this, you’ll first need to [register your platform](dashboard.stripe.com/account/applications/settings).
If you’ve already collected information for your connected accounts, you [can prefill that information](stripe.com/docs/connect/best-practices#onboarding) when creating the account. Connect Onboarding won’t ask for the prefilled information during account onboarding. You can prefill any information on the account.
38 39 40 |
# File 'lib/stripe/resources/account.rb', line 38 def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/accounts", params: params, opts: opts) end |
.delete(id, params = {}, opts = {}) ⇒ Object
With [Connect](stripe.com/docs/connect), you can delete accounts you manage.
Accounts created using test-mode keys can be deleted at any time. Standard accounts created using live-mode keys cannot be deleted. Custom or Express accounts created using live-mode keys can only be deleted once all balances are zero.
If you want to delete your own account, use the [account information tab in your account settings](dashboard.stripe.com/settings/account) instead.
47 48 49 50 51 52 53 54 |
# File 'lib/stripe/resources/account.rb', line 47 def self.delete(id, params = {}, opts = {}) request_stripe_object( method: :delete, path: format("/v1/accounts/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts ) end |
.list(filters = {}, opts = {}) ⇒ Object
Returns a list of accounts connected to your platform via [Connect](stripe.com/docs/connect). If you’re not a platform, the list is empty.
71 72 73 |
# File 'lib/stripe/resources/account.rb', line 71 def self.list(filters = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/accounts", params: filters, opts: opts) end |
.object_name ⇒ Object
20 21 22 |
# File 'lib/stripe/resources/account.rb', line 20 def self.object_name "account" end |
.persons(account, params = {}, opts = {}) ⇒ Object
Returns a list of people associated with the account’s legal entity. The people are returned sorted by creation date, with the most recent people appearing first.
86 87 88 89 90 91 92 93 |
# File 'lib/stripe/resources/account.rb', line 86 def self.persons(account, params = {}, opts = {}) request_stripe_object( method: :get, path: format("/v1/accounts/%<account>s/persons", { account: CGI.escape(account) }), params: params, opts: opts ) end |
.protected_fields ⇒ Object
206 207 208 |
# File 'lib/stripe/resources/account.rb', line 206 def self.protected_fields [:legal_entity] end |
.reject(account, params = {}, opts = {}) ⇒ Object
With [Connect](stripe.com/docs/connect), you may flag accounts as suspicious.
Test-mode Custom and Express accounts can be rejected at any time. Accounts created using live-mode keys may only be rejected once all balances are zero.
110 111 112 113 114 115 116 117 |
# File 'lib/stripe/resources/account.rb', line 110 def self.reject(account, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/accounts/%<account>s/reject", { account: CGI.escape(account) }), params: params, opts: opts ) end |
.retrieve(id = nil, opts = {}) ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/stripe/resources/account.rb', line 148 def self.retrieve(id = nil, opts = {}) Util.check_string_argument!(id) if id # Account used to be a singleton, where this method's signature was # `(opts={})`. For the sake of not breaking folks who pass in an OAuth # key in opts, let's lurkily string match for it. if opts == {} && id.is_a?(String) && id.start_with?("sk_") # `super` properly assumes a String opts is the apiKey and normalizes # as expected. opts = id id = nil end super(id, opts) end |
.update(id, params = {}, opts = {}) ⇒ Object
Updates a [connected account](stripe.com/docs/connect/accounts) by setting the values of the parameters passed. Any parameters not provided are left unchanged.
For Custom accounts, you can update any information on the account. For other accounts, you can update all information until that account has started to go through Connect Onboarding. Once you create an [Account Link or <a href=“/docs/api/account_sessions”>Account Session](stripe.com/docs/api/account_links), some properties can only be changed or updated for Custom accounts.
To update your own account, use the [Dashboard](dashboard.stripe.com/settings/account). Refer to our [Connect](stripe.com/docs/connect/updating-accounts) documentation to learn more about updating accounts.
128 129 130 131 132 133 134 135 |
# File 'lib/stripe/resources/account.rb', line 128 def self.update(id, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/accounts/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts ) end |
Instance Method Details
#deauthorize(client_id = nil, opts = {}) ⇒ Object
221 222 223 224 225 226 227 228 |
# File 'lib/stripe/resources/account.rb', line 221 def (client_id = nil, opts = {}) params = { client_id: client_id, stripe_user_id: id, } opts = @opts.merge(Util.normalize_opts(opts)) OAuth.(params, opts) end |
#delete(params = {}, opts = {}) ⇒ Object
With [Connect](stripe.com/docs/connect), you can delete accounts you manage.
Accounts created using test-mode keys can be deleted at any time. Standard accounts created using live-mode keys cannot be deleted. Custom or Express accounts created using live-mode keys can only be deleted once all balances are zero.
If you want to delete your own account, use the [account information tab in your account settings](dashboard.stripe.com/settings/account) instead.
61 62 63 64 65 66 67 68 |
# File 'lib/stripe/resources/account.rb', line 61 def delete(params = {}, opts = {}) request_stripe_object( method: :delete, path: format("/v1/accounts/%<account>s", { account: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#legal_entity ⇒ Object
210 211 212 |
# File 'lib/stripe/resources/account.rb', line 210 def legal_entity self["legal_entity"] end |
#legal_entity=(_legal_entity) ⇒ Object
214 215 216 217 218 219 |
# File 'lib/stripe/resources/account.rb', line 214 def legal_entity=(_legal_entity) raise NoMethodError, "Overriding legal_entity can cause serious issues. Instead, set " \ "the individual fields of legal_entity like " \ "`account.legal_entity.first_name = 'Blah'`" end |
#persons(params = {}, opts = {}) ⇒ Object
Returns a list of people associated with the account’s legal entity. The people are returned sorted by creation date, with the most recent people appearing first.
76 77 78 79 80 81 82 83 |
# File 'lib/stripe/resources/account.rb', line 76 def persons(params = {}, opts = {}) request_stripe_object( method: :get, path: format("/v1/accounts/%<account>s/persons", { account: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#reject(params = {}, opts = {}) ⇒ Object
With [Connect](stripe.com/docs/connect), you may flag accounts as suspicious.
Test-mode Custom and Express accounts can be rejected at any time. Accounts created using live-mode keys may only be rejected once all balances are zero.
98 99 100 101 102 103 104 105 |
# File 'lib/stripe/resources/account.rb', line 98 def reject(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/accounts/%<account>s/reject", { account: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#resource_url ⇒ Object
139 140 141 142 143 144 145 |
# File 'lib/stripe/resources/account.rb', line 139 def resource_url if self["id"] super else "/v1/account" end end |
#serialize_params(options = {}) ⇒ Object
Somewhat unfortunately, we attempt to do a special encoding trick when serializing ‘additional_owners` under an account: when updating a value, we actually send the update parameters up as an integer-indexed hash rather than an array. So instead of this:
field[]=item1&field[]=item2&field[]=item3
We send this:
field[0]=item1&field[1]=item2&field[2]=item3
There are two major problems with this technique:
* Entities are addressed by array index, which is not stable and can
easily result in unexpected results between two different requests.
* A replacement of the array's contents is ambiguous with setting a
subset of the array. Because of this, the only way to shorten an
array is to unset it completely by making sure it goes into the
server as an empty string, then setting its contents again.
We’re trying to get this overturned on the server side, but for now, patch in a special allowance.
190 191 192 |
# File 'lib/stripe/resources/account.rb', line 190 def serialize_params( = {}) serialize_params_account(self, super, ) end |
#serialize_params_account(_obj, update_hash, options = {}) ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/stripe/resources/account.rb', line 194 def serialize_params_account(_obj, update_hash, = {}) if (entity = @values[:legal_entity]) && (owners = entity[:additional_owners]) entity_update = update_hash[:legal_entity] ||= {} entity_update[:additional_owners] = serialize_additional_owners(entity, owners) end if (individual = @values[:individual]) && (individual.is_a?(Person) && !update_hash.key?(:individual)) update_hash[:individual] = individual.serialize_params() end update_hash end |