Class: Stripe::Account

Inherits:
APIResource show all
Extended by:
Gem::Deprecate, Stripe::APIOperations::Create, Stripe::APIOperations::List, Stripe::APIOperations::NestedResource
Includes:
Stripe::APIOperations::Delete, Stripe::APIOperations::Save
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) for a Standard or Express account, some parameters are no longer returned. These are marked as **Custom Only** or **Custom and Express** below. 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

#save_with_parent

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Stripe::APIOperations::Create

create

Methods included from Stripe::APIOperations::List

list

Methods included from Stripe::APIOperations::NestedResource

nested_resource_class_methods

Methods included from Stripe::APIOperations::Save

included, #save

Methods included from Stripe::APIOperations::Delete

#delete, included

Methods inherited from APIResource

class_name, custom_method, #refresh, #request_stripe_object, resource_url, save_nested_resource

Methods included from Stripe::APIOperations::Request

included

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

.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.



51
52
53
54
55
56
57
58
# File 'lib/stripe/resources/account.rb', line 51

def self.persons(, params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: format("/v1/accounts/%<account>s/persons", { account: CGI.escape() }),
    params: params,
    opts: opts
  )
end

.protected_fieldsObject



145
146
147
# File 'lib/stripe/resources/account.rb', line 145

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.



63
64
65
66
67
68
69
70
# File 'lib/stripe/resources/account.rb', line 63

def self.reject(, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/accounts/%<account>s/reject", { account: CGI.escape() }),
    params: params,
    opts: opts
  )
end

.retrieve(id = nil, opts = {}) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/stripe/resources/account.rb', line 87

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

Instance Method Details

#deauthorize(client_id = nil, opts = {}) ⇒ Object



160
161
162
163
164
165
166
167
# File 'lib/stripe/resources/account.rb', line 160

def deauthorize(client_id = nil, opts = {})
  params = {
    client_id: client_id,
    stripe_user_id: id,
  }
  opts = @opts.merge(Util.normalize_opts(opts))
  OAuth.deauthorize(params, opts)
end


149
150
151
# File 'lib/stripe/resources/account.rb', line 149

def legal_entity
  self["legal_entity"]
end

Raises:

  • (NoMethodError)


153
154
155
156
157
158
# File 'lib/stripe/resources/account.rb', line 153

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.



29
30
31
32
33
34
35
36
# File 'lib/stripe/resources/account.rb', line 29

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.



41
42
43
44
45
46
47
48
# File 'lib/stripe/resources/account.rb', line 41

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_urlObject



78
79
80
81
82
83
84
# File 'lib/stripe/resources/account.rb', line 78

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.



129
130
131
# File 'lib/stripe/resources/account.rb', line 129

def serialize_params(options = {})
  (self, super, options)
end

#serialize_params_account(_obj, update_hash, options = {}) ⇒ Object



133
134
135
136
137
138
139
140
141
142
143
# File 'lib/stripe/resources/account.rb', line 133

def (_obj, update_hash, options = {})
  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(options)
  end
  update_hash
end