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, CreateParams, Eps, Giropay, Ideal, Klarna, Multibanco, Owner, P24, Receiver, Redirect, SepaCreditTransfer, SepaDebit, Sofort, SourceOrder, ThreeDSecure, UpdateParams, VerifyParams, 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.
-
#allow_redisplay ⇒ Object
readonly
This field indicates whether this payment method can be shown again to its customer in a checkout flow.
-
#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.
-
#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(source, 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
1147 1148 1149 |
# File 'lib/stripe/resources/source.rb', line 1147 def ach_credit_transfer @ach_credit_transfer end |
#ach_debit ⇒ Object (readonly)
Attribute for field ach_debit
1149 1150 1151 |
# File 'lib/stripe/resources/source.rb', line 1149 def ach_debit @ach_debit end |
#acss_debit ⇒ Object (readonly)
Attribute for field acss_debit
1151 1152 1153 |
# File 'lib/stripe/resources/source.rb', line 1151 def acss_debit @acss_debit end |
#alipay ⇒ Object (readonly)
Attribute for field alipay
1153 1154 1155 |
# File 'lib/stripe/resources/source.rb', line 1153 def alipay @alipay end |
#allow_redisplay ⇒ Object (readonly)
This field indicates whether this payment method can be shown again to its customer in a checkout flow. Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow. The field defaults to “unspecified”.
1155 1156 1157 |
# File 'lib/stripe/resources/source.rb', line 1155 def allow_redisplay @allow_redisplay 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.
1157 1158 1159 |
# File 'lib/stripe/resources/source.rb', line 1157 def amount @amount end |
#au_becs_debit ⇒ Object (readonly)
Attribute for field au_becs_debit
1159 1160 1161 |
# File 'lib/stripe/resources/source.rb', line 1159 def au_becs_debit @au_becs_debit end |
#bancontact ⇒ Object (readonly)
Attribute for field bancontact
1161 1162 1163 |
# File 'lib/stripe/resources/source.rb', line 1161 def bancontact @bancontact end |
#card ⇒ Object (readonly)
Attribute for field card
1163 1164 1165 |
# File 'lib/stripe/resources/source.rb', line 1163 def card @card end |
#card_present ⇒ Object (readonly)
Attribute for field card_present
1165 1166 1167 |
# File 'lib/stripe/resources/source.rb', line 1165 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.
1167 1168 1169 |
# File 'lib/stripe/resources/source.rb', line 1167 def client_secret @client_secret end |
#code_verification ⇒ Object (readonly)
Attribute for field code_verification
1169 1170 1171 |
# File 'lib/stripe/resources/source.rb', line 1169 def code_verification @code_verification end |
#created ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
1171 1172 1173 |
# File 'lib/stripe/resources/source.rb', line 1171 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.
1173 1174 1175 |
# File 'lib/stripe/resources/source.rb', line 1173 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.
1175 1176 1177 |
# File 'lib/stripe/resources/source.rb', line 1175 def customer @customer end |
#eps ⇒ Object (readonly)
Attribute for field eps
1177 1178 1179 |
# File 'lib/stripe/resources/source.rb', line 1177 def eps @eps end |
#flow ⇒ Object (readonly)
The authentication ‘flow` of the source. `flow` is one of `redirect`, `receiver`, `code_verification`, `none`.
1179 1180 1181 |
# File 'lib/stripe/resources/source.rb', line 1179 def flow @flow end |
#giropay ⇒ Object (readonly)
Attribute for field giropay
1181 1182 1183 |
# File 'lib/stripe/resources/source.rb', line 1181 def giropay @giropay end |
#id ⇒ Object (readonly)
Unique identifier for the object.
1183 1184 1185 |
# File 'lib/stripe/resources/source.rb', line 1183 def id @id end |
#ideal ⇒ Object (readonly)
Attribute for field ideal
1185 1186 1187 |
# File 'lib/stripe/resources/source.rb', line 1185 def ideal @ideal end |
#klarna ⇒ Object (readonly)
Attribute for field klarna
1187 1188 1189 |
# File 'lib/stripe/resources/source.rb', line 1187 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.
1189 1190 1191 |
# File 'lib/stripe/resources/source.rb', line 1189 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.
1191 1192 1193 |
# File 'lib/stripe/resources/source.rb', line 1191 def @metadata end |
#multibanco ⇒ Object (readonly)
Attribute for field multibanco
1193 1194 1195 |
# File 'lib/stripe/resources/source.rb', line 1193 def multibanco @multibanco end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
1195 1196 1197 |
# File 'lib/stripe/resources/source.rb', line 1195 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.
1197 1198 1199 |
# File 'lib/stripe/resources/source.rb', line 1197 def owner @owner end |
#p24 ⇒ Object (readonly)
Attribute for field p24
1199 1200 1201 |
# File 'lib/stripe/resources/source.rb', line 1199 def p24 @p24 end |
#receiver ⇒ Object (readonly)
Attribute for field receiver
1201 1202 1203 |
# File 'lib/stripe/resources/source.rb', line 1201 def receiver @receiver end |
#redirect ⇒ Object (readonly)
Attribute for field redirect
1203 1204 1205 |
# File 'lib/stripe/resources/source.rb', line 1203 def redirect @redirect end |
#sepa_credit_transfer ⇒ Object (readonly)
Attribute for field sepa_credit_transfer
1205 1206 1207 |
# File 'lib/stripe/resources/source.rb', line 1205 def sepa_credit_transfer @sepa_credit_transfer end |
#sepa_debit ⇒ Object (readonly)
Attribute for field sepa_debit
1207 1208 1209 |
# File 'lib/stripe/resources/source.rb', line 1207 def sepa_debit @sepa_debit end |
#sofort ⇒ Object (readonly)
Attribute for field sofort
1209 1210 1211 |
# File 'lib/stripe/resources/source.rb', line 1209 def sofort @sofort end |
#source_order ⇒ Object (readonly)
Attribute for field source_order
1211 1212 1213 |
# File 'lib/stripe/resources/source.rb', line 1211 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.
1213 1214 1215 |
# File 'lib/stripe/resources/source.rb', line 1213 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.
1215 1216 1217 |
# File 'lib/stripe/resources/source.rb', line 1215 def status @status end |
#three_d_secure ⇒ Object (readonly)
Attribute for field three_d_secure
1217 1218 1219 |
# File 'lib/stripe/resources/source.rb', line 1217 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.
1219 1220 1221 |
# File 'lib/stripe/resources/source.rb', line 1219 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.
1221 1222 1223 |
# File 'lib/stripe/resources/source.rb', line 1221 def usage @usage end |
#wechat ⇒ Object (readonly)
Attribute for field wechat
1223 1224 1225 |
# File 'lib/stripe/resources/source.rb', line 1223 def wechat @wechat end |
Class Method Details
.create(params = {}, opts = {}) ⇒ Object
Creates a new source object.
1226 1227 1228 |
# File 'lib/stripe/resources/source.rb', line 1226 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(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](docs.stripe.com/docs/sources) for more detail.
1233 1234 1235 1236 1237 1238 1239 1240 |
# File 'lib/stripe/resources/source.rb', line 1233 def self.update(source, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/sources/%<source>s", { source: CGI.escape(source) }), params: params, opts: opts ) end |
.verify(source, params = {}, opts = {}) ⇒ Object
Verify a given source.
1253 1254 1255 1256 1257 1258 1259 1260 |
# File 'lib/stripe/resources/source.rb', line 1253 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
1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 |
# File 'lib/stripe/resources/source.rb', line 1262 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: RequestOptions.extract_opts_from_hash(opts)) end |
#source_transactions(params = {}, opts = {}) ⇒ Object
1276 1277 1278 1279 1280 1281 1282 1283 |
# File 'lib/stripe/resources/source.rb', line 1276 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.
1243 1244 1245 1246 1247 1248 1249 1250 |
# File 'lib/stripe/resources/source.rb', line 1243 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 |