Class: Stripe::SourceService

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from StripeService

#request, #request_stream

Constructor Details

#initialize(requestor) ⇒ SourceService

Returns a new instance of SourceService.



8
9
10
11
# File 'lib/stripe/services/source_service.rb', line 8

def initialize(requestor)
  super(requestor)
  @transactions = Stripe::SourceTransactionService.new(@requestor)
end

Instance Attribute Details

#transactionsObject (readonly)

Returns the value of attribute transactions.



6
7
8
# File 'lib/stripe/services/source_service.rb', line 6

def transactions
  @transactions
end

Instance Method Details

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

Creates a new source object.



14
15
16
# File 'lib/stripe/services/source_service.rb', line 14

def create(params = {}, opts = {})
  request(method: :post, path: "/v1/sources", params: params, opts: opts, base_address: :api)
end

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

Delete a specified source for a given customer.



19
20
21
22
23
24
25
26
27
# File 'lib/stripe/services/source_service.rb', line 19

def detach(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

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

Retrieves an existing source object. Supply the unique source ID from a source creation request and Stripe will return the corresponding up-to-date source object information.



30
31
32
33
34
35
36
37
38
# File 'lib/stripe/services/source_service.rb', line 30

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

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

Updates the specified source by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

This request accepts the metadata and owner as arguments. It is also possible to update type specific information for selected payment methods. Please refer to our [payment method guides](stripe.com/docs/sources) for more detail.



43
44
45
46
47
48
49
50
51
# File 'lib/stripe/services/source_service.rb', line 43

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

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

Verify a given source.



54
55
56
57
58
59
60
61
62
# File 'lib/stripe/services/source_service.rb', line 54

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