Class: Stripe::Customer
Defined Under Namespace
Classes: TestHelpers
Constant Summary
collapse
- OBJECT_NAME =
"customer"
Constants inherited
from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary
Attributes inherited from APIResource
#save_with_parent
Class Method Summary
collapse
-
.create_funding_instructions(customer, params = {}, opts = {}) ⇒ Object
-
.list_payment_methods(customer, params = {}, opts = {}) ⇒ Object
-
.retrieve_cash_balance(customer, opts_or_unused_nested_id = nil, opts = {}) ⇒ Object
-
.retrieve_payment_method(customer, payment_method, params = {}, opts = {}) ⇒ Object
-
.search(params = {}, opts = {}) ⇒ Object
-
.search_auto_paging_each(params = {}, opts = {}, &blk) ⇒ Object
-
.update_cash_balance(customer, unused_nested_id = nil, params = {}, opts = {}) ⇒ Object
Instance Method Summary
collapse
create
list
_search
nested_resource_class_methods
included, #save
#delete, included
Methods inherited from APIResource
class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource
included
#==, #[], #[]=, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Stripe::StripeObject
Class Method Details
.create_funding_instructions(customer, params = {}, opts = {}) ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'lib/stripe/resources/customer.rb', line 47
def self.create_funding_instructions(customer, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/customers/%<customer>s/funding_instructions", { customer: CGI.escape(customer) }),
params: params,
opts: opts
)
end
|
.list_payment_methods(customer, params = {}, opts = {}) ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'lib/stripe/resources/customer.rb', line 56
def self.list_payment_methods(customer, params = {}, opts = {})
request_stripe_object(
method: :get,
path: format("/v1/customers/%<customer>s/payment_methods", { customer: CGI.escape(customer) }),
params: params,
opts: opts
)
end
|
.retrieve_cash_balance(customer, opts_or_unused_nested_id = nil, opts = {}) ⇒ Object
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/stripe/resources/customer.rb', line 111
def self.retrieve_cash_balance(
customer,
opts_or_unused_nested_id = nil,
opts = {}
)
if !opts_or_unused_nested_id.nil? && opts_or_unused_nested_id.class == Hash && opts.empty?
opts = opts_or_unused_nested_id
end
request_stripe_object(
method: :get,
path: format("/v1/customers/%<customer>s/cash_balance", { customer: CGI.escape(customer) }),
params: {},
opts: opts
)
end
|
.retrieve_payment_method(customer, payment_method, params = {}, opts = {}) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/stripe/resources/customer.rb', line 65
def self.retrieve_payment_method(
customer,
payment_method,
params = {},
opts = {}
)
request_stripe_object(
method: :get,
path: format("/v1/customers/%<customer>s/payment_methods/%<payment_method>s", { customer: CGI.escape(customer), payment_method: CGI.escape(payment_method) }),
params: params,
opts: opts
)
end
|
.search(params = {}, opts = {}) ⇒ Object
103
104
105
|
# File 'lib/stripe/resources/customer.rb', line 103
def self.search(params = {}, opts = {})
_search("/v1/customers/search", params, opts)
end
|
.search_auto_paging_each(params = {}, opts = {}, &blk) ⇒ Object
107
108
109
|
# File 'lib/stripe/resources/customer.rb', line 107
def self.search_auto_paging_each(params = {}, opts = {}, &blk)
search(params, opts).auto_paging_each(&blk)
end
|
.update_cash_balance(customer, unused_nested_id = nil, params = {}, opts = {}) ⇒ Object
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# File 'lib/stripe/resources/customer.rb', line 130
def self.update_cash_balance(
customer,
unused_nested_id = nil,
params = {},
opts = {}
)
if !unused_nested_id.nil? && unused_nested_id.class == Hash
raise ArgumentError, "update_cash_balance requires the second argument always be nil for legacy reasons."
end
request_stripe_object(
method: :post,
path: format("/v1/customers/%<customer>s/cash_balance", { customer: CGI.escape(customer) }),
params: params,
opts: opts
)
end
|
Instance Method Details
#create_funding_instructions(params = {}, opts = {}) ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/stripe/resources/customer.rb', line 20
def create_funding_instructions(params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/customers/%<customer>s/funding_instructions", { customer: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end
|
#delete_discount ⇒ Object
Deletes a discount associated with the customer.
Returns the deleted discount. The customer object is not updated, so you must call ‘refresh` on it to get a new version with the discount removed.
95
96
97
98
99
100
101
|
# File 'lib/stripe/resources/customer.rb', line 95
def delete_discount
request_stripe_object(
method: :delete,
path: resource_url + "/discount",
params: {}
)
end
|
#list_payment_methods(params = {}, opts = {}) ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'lib/stripe/resources/customer.rb', line 29
def list_payment_methods(params = {}, opts = {})
request_stripe_object(
method: :get,
path: format("/v1/customers/%<customer>s/payment_methods", { customer: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end
|
#retrieve_payment_method(payment_method, params = {}, opts = {}) ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/stripe/resources/customer.rb', line 38
def retrieve_payment_method(payment_method, params = {}, opts = {})
request_stripe_object(
method: :get,
path: format("/v1/customers/%<customer>s/payment_methods/%<payment_method>s", { customer: CGI.escape(self["id"]), payment_method: CGI.escape(payment_method) }),
params: params,
opts: opts
)
end
|
#test_helpers ⇒ Object
149
150
151
|
# File 'lib/stripe/resources/customer.rb', line 149
def test_helpers
TestHelpers.new(self)
end
|