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
Attributes inherited from StripeObject
Class Method Summary collapse
-
.create(params = {}, opts = {}) ⇒ Object
Creates a new source object.
- .object_name ⇒ Object
-
.update(id, params = {}, opts = {}) ⇒ Object
Updates the specified source by setting the values of the parameters passed.
-
.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
.create(params = {}, opts = {}) ⇒ Object
Creates a new source object.
28 29 30 |
# File 'lib/stripe/resources/source.rb', line 28 def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/sources", params: params, opts: opts) end |
.object_name ⇒ Object
21 22 23 |
# File 'lib/stripe/resources/source.rb', line 21 def self.object_name "source" end |
.update(id, 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.
35 36 37 38 39 40 41 42 |
# File 'lib/stripe/resources/source.rb', line 35 def self.update(id, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/sources/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts ) end |
.verify(source, params = {}, opts = {}) ⇒ Object
Verify a given source.
55 56 57 58 59 60 61 62 |
# File 'lib/stripe/resources/source.rb', line 55 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
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/stripe/resources/source.rb', line 64 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)}" opts = Util.normalize_opts(opts) APIRequestor.active_requestor.execute_request_initialize_from(:delete, url, :api, self, params: params, opts: opts) end |
#source_transactions(params = {}, opts = {}) ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/stripe/resources/source.rb', line 78 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.
45 46 47 48 49 50 51 52 |
# File 'lib/stripe/resources/source.rb', line 45 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 |