Class: Stripe::CustomerPaymentSourceService

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

Defined Under Namespace

Classes: CreateParams, DeleteParams, ListParams, RetrieveParams, UpdateParams, VerifyParams

Instance Method Summary collapse

Methods inherited from StripeService

#initialize, #request, #request_stream

Constructor Details

This class inherits a constructor from Stripe::StripeService

Instance Method Details

#create(customer, params = {}, opts = {}) ⇒ Object

When you create a new credit card, you must specify a customer or recipient on which to create it.

If the card’s owner has no default card, then the new card will become the default. However, if the owner already has a default, then it will not change. To change the default, you should [update the customer](stripe.com/docs/api#update_customer) to have a new default_source.



190
191
192
193
194
195
196
197
198
# File 'lib/stripe/services/customer_payment_source_service.rb', line 190

def create(customer, params = {}, opts = {})
  request(
    method: :post,
    path: format("/v1/customers/%<customer>s/sources", { customer: CGI.escape(customer) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#delete(customer, id, params = {}, opts = {}) ⇒ Object

Delete a specified source for a given customer.



201
202
203
204
205
206
207
208
209
# File 'lib/stripe/services/customer_payment_source_service.rb', line 201

def delete(customer, id, params = {}, opts = {})
  request(
    method: :delete,
    path: format("/v1/customers/%<customer>s/sources/%<id>s", { customer: CGI.escape(customer), id: CGI.escape(id) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#list(customer, params = {}, opts = {}) ⇒ Object

List sources for a specified customer.



212
213
214
215
216
217
218
219
220
# File 'lib/stripe/services/customer_payment_source_service.rb', line 212

def list(customer, params = {}, opts = {})
  request(
    method: :get,
    path: format("/v1/customers/%<customer>s/sources", { customer: CGI.escape(customer) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#retrieve(customer, id, params = {}, opts = {}) ⇒ Object

Retrieve a specified source for a given customer.



223
224
225
226
227
228
229
230
231
# File 'lib/stripe/services/customer_payment_source_service.rb', line 223

def retrieve(customer, id, params = {}, opts = {})
  request(
    method: :get,
    path: format("/v1/customers/%<customer>s/sources/%<id>s", { customer: CGI.escape(customer), id: CGI.escape(id) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#update(customer, id, params = {}, opts = {}) ⇒ Object

Update a specified source for a given customer.



234
235
236
237
238
239
240
241
242
# File 'lib/stripe/services/customer_payment_source_service.rb', line 234

def update(customer, id, params = {}, opts = {})
  request(
    method: :post,
    path: format("/v1/customers/%<customer>s/sources/%<id>s", { customer: CGI.escape(customer), id: CGI.escape(id) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#verify(customer, id, params = {}, opts = {}) ⇒ Object

Verify a specified bank account for a given customer.



245
246
247
248
249
250
251
252
253
# File 'lib/stripe/services/customer_payment_source_service.rb', line 245

def verify(customer, id, params = {}, opts = {})
  request(
    method: :post,
    path: format("/v1/customers/%<customer>s/sources/%<id>s/verify", { customer: CGI.escape(customer), id: CGI.escape(id) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end