Class: Stripe::SourceService

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

Defined Under Namespace

Classes: CreateParams, DetachParams, RetrieveParams, UpdateParams, VerifyParams

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.



707
708
709
# File 'lib/stripe/services/source_service.rb', line 707

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.



712
713
714
715
716
717
718
719
720
# File 'lib/stripe/services/source_service.rb', line 712

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.



723
724
725
726
727
728
729
730
731
# File 'lib/stripe/services/source_service.rb', line 723

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.



736
737
738
739
740
741
742
743
744
# File 'lib/stripe/services/source_service.rb', line 736

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.



747
748
749
750
751
752
753
754
755
# File 'lib/stripe/services/source_service.rb', line 747

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