Class: Stripe::CustomerService

Inherits:
StripeService show all
Defined in:
lib/stripe/services/customer_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from StripeService

#request, #request_stream

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_transactionsObject (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_balanceObject (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_transactionsObject (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_instructionsObject (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_methodsObject (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_sourcesObject (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_idsObject (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.



20
21
22
# File 'lib/stripe/services/customer_service.rb', line 20

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.



25
26
27
28
29
30
31
32
33
# File 'lib/stripe/services/customer_service.rb', line 25

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.



36
37
38
39
40
41
42
43
44
# File 'lib/stripe/services/customer_service.rb', line 36

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.



47
48
49
# File 'lib/stripe/services/customer_service.rb', line 47

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.



52
53
54
55
56
57
58
59
60
# File 'lib/stripe/services/customer_service.rb', line 52

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.



66
67
68
69
70
71
72
73
74
# File 'lib/stripe/services/customer_service.rb', line 66

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.



79
80
81
82
83
84
85
86
87
# File 'lib/stripe/services/customer_service.rb', line 79

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