Class: Stripe::Source
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::Source
- Extended by:
- Gem::Deprecate, APIOperations::Create, APIOperations::NestedResource
- Includes:
- APIOperations::Save
- Defined in:
- lib/stripe/resources/source.rb
Overview
‘Source` objects allow you to accept a variety of payment methods. They represent a customer’s payment instrument, and can be used with the Stripe API just like a ‘Card` object: once chargeable, they can be charged, or can be attached to customers.
Stripe doesn’t recommend using the deprecated [Sources API](stripe.com/docs/api/sources). We recommend that you adopt the [PaymentMethods API](stripe.com/docs/api/payment_methods). This newer API provides access to our latest features and payment method types.
Related guides: [Sources API](stripe.com/docs/sources) and [Sources & Customers](stripe.com/docs/sources/customers).
Constant Summary collapse
- OBJECT_NAME =
"source"
Constants inherited from StripeObject
Stripe::StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary
Attributes inherited from APIResource
Class Method Summary collapse
-
.verify(source, params = {}, opts = {}) ⇒ Object
Verify a given source.
Instance Method Summary collapse
- #detach(params = {}, opts = {}) ⇒ Object
- #source_transactions(params = {}, opts = {}) ⇒ Object
-
#verify(params = {}, opts = {}) ⇒ Object
Verify a given source.
Methods included from APIOperations::Create
Methods included from APIOperations::NestedResource
Methods included from APIOperations::Save
Methods inherited from APIResource
class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource
Methods included from APIOperations::Request
Methods inherited from StripeObject
#==, #[], #[]=, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values
Constructor Details
This class inherits a constructor from Stripe::StripeObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject
Class Method Details
.verify(source, params = {}, opts = {}) ⇒ Object
Verify a given source.
35 36 37 38 39 40 41 42 |
# File 'lib/stripe/resources/source.rb', line 35 def self.verify(source, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/sources/%<source>s/verify", { source: CGI.escape(source) }), params: params, opts: opts ) end |
Instance Method Details
#detach(params = {}, opts = {}) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/stripe/resources/source.rb', line 44 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 = execute_resource_request(:delete, url, params, opts) initialize_from(resp.data, opts) end |
#source_transactions(params = {}, opts = {}) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/stripe/resources/source.rb', line 57 def source_transactions(params = {}, opts = {}) request_stripe_object( method: :get, path: resource_url + "/source_transactions", params: params, opts: opts ) end |
#verify(params = {}, opts = {}) ⇒ Object
Verify a given source.
25 26 27 28 29 30 31 32 |
# File 'lib/stripe/resources/source.rb', line 25 def verify(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/sources/%<source>s/verify", { source: CGI.escape(self["id"]) }), params: params, opts: opts ) end |