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).
Defined Under Namespace
Classes: AchCreditTransfer, AchDebit, AcssDebit, Alipay, AuBecsDebit, Bancontact, Card, CardPresent, CodeVerification, Eps, Giropay, Ideal, Klarna, Multibanco, Owner, P24, Paypal, Receiver, Redirect, SepaCreditTransfer, SepaDebit, Sofort, SourceOrder, ThreeDSecure, Wechat
Constant Summary collapse
- OBJECT_NAME =
"source"
Constants inherited from StripeObject
Stripe::StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary collapse
-
#ach_credit_transfer ⇒ Object
readonly
Attribute for field ach_credit_transfer.
-
#ach_debit ⇒ Object
readonly
Attribute for field ach_debit.
-
#acss_debit ⇒ Object
readonly
Attribute for field acss_debit.
-
#alipay ⇒ Object
readonly
Attribute for field alipay.
-
#amount ⇒ Object
readonly
A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the total amount associated with the source.
-
#au_becs_debit ⇒ Object
readonly
Attribute for field au_becs_debit.
-
#bancontact ⇒ Object
readonly
Attribute for field bancontact.
-
#card ⇒ Object
readonly
Attribute for field card.
-
#card_present ⇒ Object
readonly
Attribute for field card_present.
-
#client_secret ⇒ Object
readonly
The client secret of the source.
-
#code_verification ⇒ Object
readonly
Attribute for field code_verification.
-
#created ⇒ Object
readonly
Time at which the object was created.
-
#currency ⇒ Object
readonly
Three-letter [ISO code for the currency](stripe.com/docs/currencies) associated with the source.
-
#customer ⇒ Object
readonly
The ID of the customer to which this source is attached.
-
#eps ⇒ Object
readonly
Attribute for field eps.
-
#flow ⇒ Object
readonly
The authentication ‘flow` of the source.
-
#giropay ⇒ Object
readonly
Attribute for field giropay.
-
#id ⇒ Object
readonly
Unique identifier for the object.
-
#ideal ⇒ Object
readonly
Attribute for field ideal.
-
#klarna ⇒ Object
readonly
Attribute for field klarna.
-
#livemode ⇒ Object
readonly
Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.
-
#metadata ⇒ Object
readonly
Set of [key-value pairs](stripe.com/docs/api/metadata) that you can attach to an object.
-
#multibanco ⇒ Object
readonly
Attribute for field multibanco.
-
#object ⇒ Object
readonly
String representing the object’s type.
-
#owner ⇒ Object
readonly
Information about the owner of the payment instrument that may be used or required by particular source types.
-
#p24 ⇒ Object
readonly
Attribute for field p24.
-
#paypal ⇒ Object
readonly
Attribute for field paypal.
-
#receiver ⇒ Object
readonly
Attribute for field receiver.
-
#redirect ⇒ Object
readonly
Attribute for field redirect.
-
#sepa_credit_transfer ⇒ Object
readonly
Attribute for field sepa_credit_transfer.
-
#sepa_debit ⇒ Object
readonly
Attribute for field sepa_debit.
-
#sofort ⇒ Object
readonly
Attribute for field sofort.
-
#source_order ⇒ Object
readonly
Attribute for field source_order.
-
#statement_descriptor ⇒ Object
readonly
Extra information about a source.
-
#status ⇒ Object
readonly
The status of the source, one of ‘canceled`, `chargeable`, `consumed`, `failed`, or `pending`.
-
#three_d_secure ⇒ Object
readonly
Attribute for field three_d_secure.
-
#type ⇒ Object
readonly
The ‘type` of the source.
-
#usage ⇒ Object
readonly
Either ‘reusable` or `single_use`.
-
#wechat ⇒ Object
readonly
Attribute for field wechat.
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
Instance Attribute Details
#ach_credit_transfer ⇒ Object (readonly)
Attribute for field ach_credit_transfer
144 145 146 |
# File 'lib/stripe/resources/source.rb', line 144 def ach_credit_transfer @ach_credit_transfer end |
#ach_debit ⇒ Object (readonly)
Attribute for field ach_debit
146 147 148 |
# File 'lib/stripe/resources/source.rb', line 146 def ach_debit @ach_debit end |
#acss_debit ⇒ Object (readonly)
Attribute for field acss_debit
148 149 150 |
# File 'lib/stripe/resources/source.rb', line 148 def acss_debit @acss_debit end |
#alipay ⇒ Object (readonly)
Attribute for field alipay
150 151 152 |
# File 'lib/stripe/resources/source.rb', line 150 def alipay @alipay end |
#amount ⇒ Object (readonly)
A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the total amount associated with the source. This is the amount for which the source will be chargeable once ready. Required for ‘single_use` sources.
152 153 154 |
# File 'lib/stripe/resources/source.rb', line 152 def amount @amount end |
#au_becs_debit ⇒ Object (readonly)
Attribute for field au_becs_debit
154 155 156 |
# File 'lib/stripe/resources/source.rb', line 154 def au_becs_debit @au_becs_debit end |
#bancontact ⇒ Object (readonly)
Attribute for field bancontact
156 157 158 |
# File 'lib/stripe/resources/source.rb', line 156 def bancontact @bancontact end |
#card ⇒ Object (readonly)
Attribute for field card
158 159 160 |
# File 'lib/stripe/resources/source.rb', line 158 def card @card end |
#card_present ⇒ Object (readonly)
Attribute for field card_present
160 161 162 |
# File 'lib/stripe/resources/source.rb', line 160 def card_present @card_present end |
#client_secret ⇒ Object (readonly)
The client secret of the source. Used for client-side retrieval using a publishable key.
162 163 164 |
# File 'lib/stripe/resources/source.rb', line 162 def client_secret @client_secret end |
#code_verification ⇒ Object (readonly)
Attribute for field code_verification
164 165 166 |
# File 'lib/stripe/resources/source.rb', line 164 def code_verification @code_verification end |
#created ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
166 167 168 |
# File 'lib/stripe/resources/source.rb', line 166 def created @created end |
#currency ⇒ Object (readonly)
Three-letter [ISO code for the currency](stripe.com/docs/currencies) associated with the source. This is the currency for which the source will be chargeable once ready. Required for ‘single_use` sources.
168 169 170 |
# File 'lib/stripe/resources/source.rb', line 168 def currency @currency end |
#customer ⇒ Object (readonly)
The ID of the customer to which this source is attached. This will not be present when the source has not been attached to a customer.
170 171 172 |
# File 'lib/stripe/resources/source.rb', line 170 def customer @customer end |
#eps ⇒ Object (readonly)
Attribute for field eps
172 173 174 |
# File 'lib/stripe/resources/source.rb', line 172 def eps @eps end |
#flow ⇒ Object (readonly)
The authentication ‘flow` of the source. `flow` is one of `redirect`, `receiver`, `code_verification`, `none`.
174 175 176 |
# File 'lib/stripe/resources/source.rb', line 174 def flow @flow end |
#giropay ⇒ Object (readonly)
Attribute for field giropay
176 177 178 |
# File 'lib/stripe/resources/source.rb', line 176 def giropay @giropay end |
#id ⇒ Object (readonly)
Unique identifier for the object.
178 179 180 |
# File 'lib/stripe/resources/source.rb', line 178 def id @id end |
#ideal ⇒ Object (readonly)
Attribute for field ideal
180 181 182 |
# File 'lib/stripe/resources/source.rb', line 180 def ideal @ideal end |
#klarna ⇒ Object (readonly)
Attribute for field klarna
182 183 184 |
# File 'lib/stripe/resources/source.rb', line 182 def klarna @klarna end |
#livemode ⇒ Object (readonly)
Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.
184 185 186 |
# File 'lib/stripe/resources/source.rb', line 184 def livemode @livemode end |
#metadata ⇒ Object (readonly)
Set of [key-value pairs](stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
186 187 188 |
# File 'lib/stripe/resources/source.rb', line 186 def @metadata end |
#multibanco ⇒ Object (readonly)
Attribute for field multibanco
188 189 190 |
# File 'lib/stripe/resources/source.rb', line 188 def multibanco @multibanco end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
190 191 192 |
# File 'lib/stripe/resources/source.rb', line 190 def object @object end |
#owner ⇒ Object (readonly)
Information about the owner of the payment instrument that may be used or required by particular source types.
192 193 194 |
# File 'lib/stripe/resources/source.rb', line 192 def owner @owner end |
#p24 ⇒ Object (readonly)
Attribute for field p24
194 195 196 |
# File 'lib/stripe/resources/source.rb', line 194 def p24 @p24 end |
#paypal ⇒ Object (readonly)
Attribute for field paypal
196 197 198 |
# File 'lib/stripe/resources/source.rb', line 196 def paypal @paypal end |
#receiver ⇒ Object (readonly)
Attribute for field receiver
198 199 200 |
# File 'lib/stripe/resources/source.rb', line 198 def receiver @receiver end |
#redirect ⇒ Object (readonly)
Attribute for field redirect
200 201 202 |
# File 'lib/stripe/resources/source.rb', line 200 def redirect @redirect end |
#sepa_credit_transfer ⇒ Object (readonly)
Attribute for field sepa_credit_transfer
202 203 204 |
# File 'lib/stripe/resources/source.rb', line 202 def sepa_credit_transfer @sepa_credit_transfer end |
#sepa_debit ⇒ Object (readonly)
Attribute for field sepa_debit
204 205 206 |
# File 'lib/stripe/resources/source.rb', line 204 def sepa_debit @sepa_debit end |
#sofort ⇒ Object (readonly)
Attribute for field sofort
206 207 208 |
# File 'lib/stripe/resources/source.rb', line 206 def sofort @sofort end |
#source_order ⇒ Object (readonly)
Attribute for field source_order
208 209 210 |
# File 'lib/stripe/resources/source.rb', line 208 def source_order @source_order end |
#statement_descriptor ⇒ Object (readonly)
Extra information about a source. This will appear on your customer’s statement every time you charge the source.
210 211 212 |
# File 'lib/stripe/resources/source.rb', line 210 def statement_descriptor @statement_descriptor end |
#status ⇒ Object (readonly)
The status of the source, one of ‘canceled`, `chargeable`, `consumed`, `failed`, or `pending`. Only `chargeable` sources can be used to create a charge.
212 213 214 |
# File 'lib/stripe/resources/source.rb', line 212 def status @status end |
#three_d_secure ⇒ Object (readonly)
Attribute for field three_d_secure
214 215 216 |
# File 'lib/stripe/resources/source.rb', line 214 def three_d_secure @three_d_secure end |
#type ⇒ Object (readonly)
The ‘type` of the source. The `type` is a payment method, one of `ach_credit_transfer`, `ach_debit`, `alipay`, `bancontact`, `card`, `card_present`, `eps`, `giropay`, `ideal`, `multibanco`, `klarna`, `p24`, `sepa_debit`, `sofort`, `three_d_secure`, or `wechat`. An additional hash is included on the source with a name matching this value. It contains additional information specific to the [payment method](stripe.com/docs/sources) used.
216 217 218 |
# File 'lib/stripe/resources/source.rb', line 216 def type @type end |
#usage ⇒ Object (readonly)
Either ‘reusable` or `single_use`. Whether this source should be reusable or not. Some source types may or may not be reusable by construction, while others may leave the option at creation. If an incompatible value is passed, an error will be returned.
218 219 220 |
# File 'lib/stripe/resources/source.rb', line 218 def usage @usage end |
#wechat ⇒ Object (readonly)
Attribute for field wechat
220 221 222 |
# File 'lib/stripe/resources/source.rb', line 220 def wechat @wechat end |
Class Method Details
.create(params = {}, opts = {}) ⇒ Object
Creates a new source object.
223 224 225 |
# File 'lib/stripe/resources/source.rb', line 223 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.
230 231 232 233 234 235 236 237 |
# File 'lib/stripe/resources/source.rb', line 230 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.
250 251 252 253 254 255 256 257 |
# File 'lib/stripe/resources/source.rb', line 250 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
259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/stripe/resources/source.rb', line 259 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
273 274 275 276 277 278 279 280 |
# File 'lib/stripe/resources/source.rb', line 273 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.
240 241 242 243 244 245 246 247 |
# File 'lib/stripe/resources/source.rb', line 240 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 |