Class: Stripe::CustomerService
- Inherits:
-
StripeService
- Object
- StripeService
- Stripe::CustomerService
- Defined in:
- lib/stripe/services/customer_service.rb
Defined Under Namespace
Classes: CreateParams, DeleteDiscountParams, DeleteParams, ListParams, RetrieveParams, SearchParams, UpdateParams
Instance Attribute Summary collapse
-
#balance_transactions ⇒ Object
readonly
Returns the value of attribute balance_transactions.
-
#cash_balance ⇒ Object
readonly
Returns the value of attribute cash_balance.
-
#cash_balance_transactions ⇒ Object
readonly
Returns the value of attribute cash_balance_transactions.
-
#funding_instructions ⇒ Object
readonly
Returns the value of attribute funding_instructions.
-
#payment_methods ⇒ Object
readonly
Returns the value of attribute payment_methods.
-
#payment_sources ⇒ Object
readonly
Returns the value of attribute payment_sources.
-
#tax_ids ⇒ Object
readonly
Returns the value of attribute tax_ids.
Instance Method Summary collapse
-
#create(params = {}, opts = {}) ⇒ Object
Creates a new customer object.
-
#delete(customer, params = {}, opts = {}) ⇒ Object
Permanently deletes a customer.
-
#delete_discount(customer, params = {}, opts = {}) ⇒ Object
Removes the currently applied discount on a customer.
-
#initialize(requestor) ⇒ CustomerService
constructor
A new instance of CustomerService.
-
#list(params = {}, opts = {}) ⇒ Object
Returns a list of your customers.
-
#retrieve(customer, params = {}, opts = {}) ⇒ Object
Retrieves a Customer object.
-
#search(params = {}, opts = {}) ⇒ Object
Search for customers you’ve previously created using Stripe’s [Search Query Language](stripe.com/docs/search#search-query-language).
-
#update(customer, params = {}, opts = {}) ⇒ Object
Updates the specified customer by setting the values of the parameters passed.
Methods inherited from StripeService
Constructor Details
#initialize(requestor) ⇒ CustomerService
Returns a new instance of CustomerService.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/stripe/services/customer_service.rb', line 8 def initialize(requestor) super(requestor) @cash_balance = Stripe::CustomerCashBalanceService.new(@requestor) @balance_transactions = Stripe::CustomerBalanceTransactionService.new(@requestor) @cash_balance_transactions = Stripe::CustomerCashBalanceTransactionService.new(@requestor) @payment_sources = Stripe::CustomerPaymentSourceService.new(@requestor) @tax_ids = Stripe::CustomerTaxIdService.new(@requestor) @payment_methods = Stripe::CustomerPaymentMethodService.new(@requestor) @funding_instructions = Stripe::CustomerFundingInstructionsService.new(@requestor) end |
Instance Attribute Details
#balance_transactions ⇒ Object (readonly)
Returns the value of attribute balance_transactions.
6 7 8 |
# File 'lib/stripe/services/customer_service.rb', line 6 def balance_transactions @balance_transactions end |
#cash_balance ⇒ Object (readonly)
Returns the value of attribute cash_balance.
6 7 8 |
# File 'lib/stripe/services/customer_service.rb', line 6 def cash_balance @cash_balance end |
#cash_balance_transactions ⇒ Object (readonly)
Returns the value of attribute cash_balance_transactions.
6 7 8 |
# File 'lib/stripe/services/customer_service.rb', line 6 def cash_balance_transactions @cash_balance_transactions end |
#funding_instructions ⇒ Object (readonly)
Returns the value of attribute funding_instructions.
6 7 8 |
# File 'lib/stripe/services/customer_service.rb', line 6 def funding_instructions @funding_instructions end |
#payment_methods ⇒ Object (readonly)
Returns the value of attribute payment_methods.
6 7 8 |
# File 'lib/stripe/services/customer_service.rb', line 6 def payment_methods @payment_methods end |
#payment_sources ⇒ Object (readonly)
Returns the value of attribute payment_sources.
6 7 8 |
# File 'lib/stripe/services/customer_service.rb', line 6 def payment_sources @payment_sources end |
#tax_ids ⇒ Object (readonly)
Returns the value of attribute tax_ids.
6 7 8 |
# File 'lib/stripe/services/customer_service.rb', line 6 def tax_ids @tax_ids end |
Instance Method Details
#create(params = {}, opts = {}) ⇒ Object
Creates a new customer object.
704 705 706 |
# File 'lib/stripe/services/customer_service.rb', line 704 def create(params = {}, opts = {}) request(method: :post, path: "/v1/customers", params: params, opts: opts, base_address: :api) end |
#delete(customer, params = {}, opts = {}) ⇒ Object
Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer.
709 710 711 712 713 714 715 716 717 |
# File 'lib/stripe/services/customer_service.rb', line 709 def delete(customer, params = {}, opts = {}) request( method: :delete, path: format("/v1/customers/%<customer>s", { customer: CGI.escape(customer) }), params: params, opts: opts, base_address: :api ) end |
#delete_discount(customer, params = {}, opts = {}) ⇒ Object
Removes the currently applied discount on a customer.
720 721 722 723 724 725 726 727 728 |
# File 'lib/stripe/services/customer_service.rb', line 720 def delete_discount(customer, params = {}, opts = {}) request( method: :delete, path: format("/v1/customers/%<customer>s/discount", { customer: CGI.escape(customer) }), params: params, opts: opts, base_address: :api ) 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.
731 732 733 |
# File 'lib/stripe/services/customer_service.rb', line 731 def list(params = {}, opts = {}) request(method: :get, path: "/v1/customers", params: params, opts: opts, base_address: :api) end |
#retrieve(customer, params = {}, opts = {}) ⇒ Object
Retrieves a Customer object.
736 737 738 739 740 741 742 743 744 |
# File 'lib/stripe/services/customer_service.rb', line 736 def retrieve(customer, params = {}, opts = {}) request( method: :get, path: format("/v1/customers/%<customer>s", { customer: CGI.escape(customer) }), params: params, opts: opts, base_address: :api ) end |
#search(params = {}, opts = {}) ⇒ Object
Search for customers you’ve previously created using Stripe’s [Search Query Language](stripe.com/docs/search#search-query-language). Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up to an hour behind during outages. Search functionality is not available to merchants in India.
750 751 752 753 754 755 756 757 758 |
# File 'lib/stripe/services/customer_service.rb', line 750 def search(params = {}, opts = {}) request( method: :get, path: "/v1/customers/search", params: params, opts: opts, base_address: :api ) end |
#update(customer, 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.
763 764 765 766 767 768 769 770 771 |
# File 'lib/stripe/services/customer_service.rb', line 763 def update(customer, params = {}, opts = {}) request( method: :post, path: format("/v1/customers/%<customer>s", { customer: CGI.escape(customer) }), params: params, opts: opts, base_address: :api ) end |