Sha256: d9f357f422db41bd00420ab9b1c29d72e2c2f1f2505e028f1ac3f48b94d2c8da

Contents?: true

Size: 1.11 KB

Versions: 14

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Stripe
  class Source < APIResource
    extend Stripe::APIOperations::Create
    include Stripe::APIOperations::Save

    OBJECT_NAME = "source"

    custom_method :verify, http_verb: :post

    def verify(params = {}, opts = {})
      request_stripe_object(
        method: :post,
        path: resource_url + "/verify",
        params: params,
        opts: opts
      )
    end

    def detach(params = {}, opts = {})
      if !respond_to?(:customer) || customer.nil? || customer.empty?
        raise NotImplementedError,
              "This source object does not appear to be currently attached " \
              "to a customer object."
      end

      url = "#{Customer.resource_url}/#{CGI.escape(customer)}/sources" \
            "/#{CGI.escape(id)}"
      resp, opts = request(:delete, url, params, opts)
      initialize_from(resp.data, opts)
    end

    def source_transactions(params = {}, opts = {})
      resp, opts = request(:get, resource_url + "/source_transactions", params,
                           opts)
      Util.convert_to_stripe_object(resp.data, opts)
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
stripe-5.9.0 lib/stripe/resources/source.rb
stripe-5.8.0 lib/stripe/resources/source.rb
stripe-5.7.1 lib/stripe/resources/source.rb
stripe-5.7.0 lib/stripe/resources/source.rb
stripe-5.6.0 lib/stripe/resources/source.rb
stripe-5.5.0 lib/stripe/resources/source.rb
stripe-5.4.1 lib/stripe/resources/source.rb
stripe-5.4.0 lib/stripe/resources/source.rb
stripe-5.3.0 lib/stripe/resources/source.rb
stripe-5.2.0 lib/stripe/resources/source.rb
stripe-5.1.1 lib/stripe/resources/source.rb
stripe-5.1.0 lib/stripe/resources/source.rb
stripe-5.0.1 lib/stripe/resources/source.rb
stripe-5.0.0 lib/stripe/resources/source.rb