Class: Stripe::Customer
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::Customer
- Extended by:
- APIOperations::Create, APIOperations::List, APIOperations::NestedResource, APIOperations::Search
- Includes:
- APIOperations::Delete, APIOperations::Save
- Defined in:
- lib/stripe/resources/customer.rb
Overview
This object represents a customer of your business. Use it to [create recurring charges](stripe.com/docs/invoicing/customer), [save payment](stripe.com/docs/payments/save-during-payment) and contact information, and track payments that belong to the same 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
Attributes inherited from StripeObject
Class Method Summary collapse
-
.create(params = {}, opts = {}) ⇒ Object
Creates a new customer object.
-
.create_funding_instructions(customer, params = {}, opts = {}) ⇒ Object
Retrieve funding instructions for a customer cash balance.
-
.delete(id, params = {}, opts = {}) ⇒ Object
Permanently deletes a customer.
-
.delete_discount(customer, params = {}, opts = {}) ⇒ Object
Removes the currently applied discount on a customer.
-
.list(params = {}, opts = {}) ⇒ Object
Returns a list of your customers.
-
.list_payment_methods(customer, params = {}, opts = {}) ⇒ Object
Returns a list of PaymentMethods for a given Customer.
- .object_name ⇒ Object
-
.retrieve_cash_balance(customer, params = {}, opts = {}) ⇒ Object
Retrieves a customer’s cash balance.
-
.retrieve_payment_method(customer, payment_method, params = {}, opts = {}) ⇒ Object
Retrieves a PaymentMethod object for a given Customer.
- .search(params = {}, opts = {}) ⇒ Object
- .search_auto_paging_each(params = {}, opts = {}, &blk) ⇒ Object
-
.update(id, params = {}, opts = {}) ⇒ Object
Updates the specified customer by setting the values of the parameters passed.
-
.update_cash_balance(customer, params = {}, opts = {}) ⇒ Object
Changes the settings on a customer’s cash balance.
Instance Method Summary collapse
-
#create_funding_instructions(params = {}, opts = {}) ⇒ Object
Retrieve funding instructions for a customer cash balance.
-
#delete(params = {}, opts = {}) ⇒ Object
Permanently deletes a customer.
-
#delete_discount(params = {}, opts = {}) ⇒ Object
Removes the currently applied discount on a customer.
-
#list_payment_methods(params = {}, opts = {}) ⇒ Object
Returns a list of PaymentMethods for a given Customer.
-
#retrieve_payment_method(payment_method, params = {}, opts = {}) ⇒ Object
Retrieves a PaymentMethod object for a given Customer.
- #test_helpers ⇒ Object
Methods included from APIOperations::Create
Methods included from APIOperations::List
Methods included from APIOperations::NestedResource
Methods included from APIOperations::Search
Methods included from APIOperations::Save
Methods included from APIOperations::Delete
Methods inherited from APIResource
class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource
Methods included from 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, protected_fields, #serialize_params, #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
Creates a new customer object.
26 27 28 |
# File 'lib/stripe/resources/customer.rb', line 26 def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/customers", params: params, opts: opts) end |
.create_funding_instructions(customer, params = {}, opts = {}) ⇒ Object
Retrieve funding instructions for a customer cash balance. If funding instructions do not yet exist for the customer, new funding instructions will be created. If funding instructions have already been created for a given customer, the same funding instructions will be retrieved. In other words, we will return the same funding instructions each time.
45 46 47 48 49 50 51 52 |
# File 'lib/stripe/resources/customer.rb', line 45 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 |
.delete(id, params = {}, opts = {}) ⇒ Object
Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer.
55 56 57 58 59 60 61 62 |
# File 'lib/stripe/resources/customer.rb', line 55 def self.delete(id, params = {}, opts = {}) request_stripe_object( method: :delete, path: format("/v1/customers/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts ) end |
.delete_discount(customer, params = {}, opts = {}) ⇒ Object
Removes the currently applied discount on a customer.
85 86 87 88 89 90 91 92 |
# File 'lib/stripe/resources/customer.rb', line 85 def self.delete_discount(customer, params = {}, opts = {}) request_stripe_object( method: :delete, path: format("/v1/customers/%<customer>s/discount", { customer: CGI.escape(customer) }), params: params, opts: opts ) end |
.list(params = {}, opts = {}) ⇒ Object
Returns a list of your customers. The customers are returned sorted by creation date, with the most recent customers appearing first.
95 96 97 |
# File 'lib/stripe/resources/customer.rb', line 95 def self.list(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/customers", params: params, opts: opts) end |
.list_payment_methods(customer, params = {}, opts = {}) ⇒ Object
Returns a list of PaymentMethods for a given Customer
110 111 112 113 114 115 116 117 |
# File 'lib/stripe/resources/customer.rb', line 110 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 |
.object_name ⇒ Object
16 17 18 |
# File 'lib/stripe/resources/customer.rb', line 16 def self.object_name "customer" end |
.retrieve_cash_balance(customer, params = {}, opts = {}) ⇒ Object
Retrieves a customer’s cash balance.
120 121 122 123 124 125 126 127 |
# File 'lib/stripe/resources/customer.rb', line 120 def self.retrieve_cash_balance(customer, params = {}, opts = {}) request_stripe_object( method: :get, path: format("/v1/customers/%<customer>s/cash_balance", { customer: CGI.escape(customer) }), params: params, opts: opts ) end |
.retrieve_payment_method(customer, payment_method, params = {}, opts = {}) ⇒ Object
Retrieves a PaymentMethod object for a given Customer.
140 141 142 143 144 145 146 147 |
# File 'lib/stripe/resources/customer.rb', line 140 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
149 150 151 |
# File 'lib/stripe/resources/customer.rb', line 149 def self.search(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/customers/search", params: params, opts: opts) end |
.search_auto_paging_each(params = {}, opts = {}, &blk) ⇒ Object
153 154 155 |
# File 'lib/stripe/resources/customer.rb', line 153 def self.search_auto_paging_each(params = {}, opts = {}, &blk) search(params, opts).auto_paging_each(&blk) end |
.update(id, params = {}, opts = {}) ⇒ Object
Updates the specified customer by setting the values of the parameters passed. Any parameters not provided will be left unchanged. For example, if you pass the source parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges in the future. When you update a customer to a new valid card source by passing the source parameter: for each of the customer’s current subscriptions, if the subscription bills automatically and is in the past_due state, then the latest open invoice for the subscription with automatic collection enabled will be retried. This retry will not count as an automatic retry, and will not affect the next regularly scheduled payment for the invoice. Changing the default_source for a customer will not trigger this behavior.
This request accepts mostly the same arguments as the customer creation call.
160 161 162 163 164 165 166 167 |
# File 'lib/stripe/resources/customer.rb', line 160 def self.update(id, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/customers/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts ) end |
.update_cash_balance(customer, params = {}, opts = {}) ⇒ Object
Changes the settings on a customer’s cash balance.
170 171 172 173 174 175 176 177 |
# File 'lib/stripe/resources/customer.rb', line 170 def self.update_cash_balance(customer, params = {}, opts = {}) 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
Retrieve funding instructions for a customer cash balance. If funding instructions do not yet exist for the customer, new funding instructions will be created. If funding instructions have already been created for a given customer, the same funding instructions will be retrieved. In other words, we will return the same funding instructions each time.
33 34 35 36 37 38 39 40 |
# File 'lib/stripe/resources/customer.rb', line 33 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(params = {}, opts = {}) ⇒ Object
Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer.
65 66 67 68 69 70 71 72 |
# File 'lib/stripe/resources/customer.rb', line 65 def delete(params = {}, opts = {}) request_stripe_object( method: :delete, path: format("/v1/customers/%<customer>s", { customer: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#delete_discount(params = {}, opts = {}) ⇒ Object
Removes the currently applied discount on a customer.
75 76 77 78 79 80 81 82 |
# File 'lib/stripe/resources/customer.rb', line 75 def delete_discount(params = {}, opts = {}) request_stripe_object( method: :delete, path: format("/v1/customers/%<customer>s/discount", { customer: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#list_payment_methods(params = {}, opts = {}) ⇒ Object
Returns a list of PaymentMethods for a given Customer
100 101 102 103 104 105 106 107 |
# File 'lib/stripe/resources/customer.rb', line 100 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
Retrieves a PaymentMethod object for a given Customer.
130 131 132 133 134 135 136 137 |
# File 'lib/stripe/resources/customer.rb', line 130 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
187 188 189 |
# File 'lib/stripe/resources/customer.rb', line 187 def test_helpers TestHelpers.new(self) end |