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](docs.stripe.com/api/sources). We recommend that you adopt the [PaymentMethods API](docs.stripe.com/api/payment_methods). This newer API provides access to our latest features and payment method types.
Related guides: [Sources API](docs.stripe.com/sources) and [Sources & Customers](docs.stripe.com/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.
-
#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
If the object exists in live mode, the value is ‘true`.
-
#metadata ⇒ Object
readonly
Set of [key-value pairs](docs.stripe.com/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.
- .field_remappings ⇒ Object
- .inner_class_types ⇒ 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
#==, #[], #[]=, #_get_inner_class_type, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, field_encodings, #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
834 835 836 |
# File 'lib/stripe/resources/source.rb', line 834 def ach_credit_transfer @ach_credit_transfer end |
#ach_debit ⇒ Object (readonly)
Attribute for field ach_debit
836 837 838 |
# File 'lib/stripe/resources/source.rb', line 836 def ach_debit @ach_debit end |
#acss_debit ⇒ Object (readonly)
Attribute for field acss_debit
838 839 840 |
# File 'lib/stripe/resources/source.rb', line 838 def acss_debit @acss_debit end |
#alipay ⇒ Object (readonly)
Attribute for field alipay
840 841 842 |
# File 'lib/stripe/resources/source.rb', line 840 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”.
842 843 844 |
# File 'lib/stripe/resources/source.rb', line 842 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.
844 845 846 |
# File 'lib/stripe/resources/source.rb', line 844 def amount @amount end |
#au_becs_debit ⇒ Object (readonly)
Attribute for field au_becs_debit
846 847 848 |
# File 'lib/stripe/resources/source.rb', line 846 def au_becs_debit @au_becs_debit end |
#bancontact ⇒ Object (readonly)
Attribute for field bancontact
848 849 850 |
# File 'lib/stripe/resources/source.rb', line 848 def bancontact @bancontact end |
#card ⇒ Object (readonly)
Attribute for field card
850 851 852 |
# File 'lib/stripe/resources/source.rb', line 850 def card @card end |
#card_present ⇒ Object (readonly)
Attribute for field card_present
852 853 854 |
# File 'lib/stripe/resources/source.rb', line 852 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.
854 855 856 |
# File 'lib/stripe/resources/source.rb', line 854 def client_secret @client_secret end |
#code_verification ⇒ Object (readonly)
Attribute for field code_verification
856 857 858 |
# File 'lib/stripe/resources/source.rb', line 856 def code_verification @code_verification end |
#created ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
858 859 860 |
# File 'lib/stripe/resources/source.rb', line 858 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.
860 861 862 |
# File 'lib/stripe/resources/source.rb', line 860 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.
862 863 864 |
# File 'lib/stripe/resources/source.rb', line 862 def customer @customer end |
#eps ⇒ Object (readonly)
Attribute for field eps
864 865 866 |
# File 'lib/stripe/resources/source.rb', line 864 def eps @eps end |
#flow ⇒ Object (readonly)
The authentication ‘flow` of the source. `flow` is one of `redirect`, `receiver`, `code_verification`, `none`.
866 867 868 |
# File 'lib/stripe/resources/source.rb', line 866 def flow @flow end |
#giropay ⇒ Object (readonly)
Attribute for field giropay
868 869 870 |
# File 'lib/stripe/resources/source.rb', line 868 def giropay @giropay end |
#id ⇒ Object (readonly)
Unique identifier for the object.
870 871 872 |
# File 'lib/stripe/resources/source.rb', line 870 def id @id end |
#ideal ⇒ Object (readonly)
Attribute for field ideal
872 873 874 |
# File 'lib/stripe/resources/source.rb', line 872 def ideal @ideal end |
#klarna ⇒ Object (readonly)
Attribute for field klarna
874 875 876 |
# File 'lib/stripe/resources/source.rb', line 874 def klarna @klarna end |
#livemode ⇒ Object (readonly)
If the object exists in live mode, the value is ‘true`. If the object exists in test mode, the value is `false`.
876 877 878 |
# File 'lib/stripe/resources/source.rb', line 876 def livemode @livemode end |
#metadata ⇒ Object (readonly)
Set of [key-value pairs](docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
878 879 880 |
# File 'lib/stripe/resources/source.rb', line 878 def @metadata end |
#multibanco ⇒ Object (readonly)
Attribute for field multibanco
880 881 882 |
# File 'lib/stripe/resources/source.rb', line 880 def multibanco @multibanco end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
882 883 884 |
# File 'lib/stripe/resources/source.rb', line 882 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.
884 885 886 |
# File 'lib/stripe/resources/source.rb', line 884 def owner @owner end |
#p24 ⇒ Object (readonly)
Attribute for field p24
886 887 888 |
# File 'lib/stripe/resources/source.rb', line 886 def p24 @p24 end |
#paypal ⇒ Object (readonly)
Attribute for field paypal
888 889 890 |
# File 'lib/stripe/resources/source.rb', line 888 def paypal @paypal end |
#receiver ⇒ Object (readonly)
Attribute for field receiver
890 891 892 |
# File 'lib/stripe/resources/source.rb', line 890 def receiver @receiver end |
#redirect ⇒ Object (readonly)
Attribute for field redirect
892 893 894 |
# File 'lib/stripe/resources/source.rb', line 892 def redirect @redirect end |
#sepa_credit_transfer ⇒ Object (readonly)
Attribute for field sepa_credit_transfer
894 895 896 |
# File 'lib/stripe/resources/source.rb', line 894 def sepa_credit_transfer @sepa_credit_transfer end |
#sepa_debit ⇒ Object (readonly)
Attribute for field sepa_debit
896 897 898 |
# File 'lib/stripe/resources/source.rb', line 896 def sepa_debit @sepa_debit end |
#sofort ⇒ Object (readonly)
Attribute for field sofort
898 899 900 |
# File 'lib/stripe/resources/source.rb', line 898 def sofort @sofort end |
#source_order ⇒ Object (readonly)
Attribute for field source_order
900 901 902 |
# File 'lib/stripe/resources/source.rb', line 900 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.
902 903 904 |
# File 'lib/stripe/resources/source.rb', line 902 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.
904 905 906 |
# File 'lib/stripe/resources/source.rb', line 904 def status @status end |
#three_d_secure ⇒ Object (readonly)
Attribute for field three_d_secure
906 907 908 |
# File 'lib/stripe/resources/source.rb', line 906 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](docs.stripe.com/sources) used.
908 909 910 |
# File 'lib/stripe/resources/source.rb', line 908 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.
910 911 912 |
# File 'lib/stripe/resources/source.rb', line 910 def usage @usage end |
#wechat ⇒ Object (readonly)
Attribute for field wechat
912 913 914 |
# File 'lib/stripe/resources/source.rb', line 912 def wechat @wechat end |
Class Method Details
.create(params = {}, opts = {}) ⇒ Object
Creates a new source object.
915 916 917 |
# File 'lib/stripe/resources/source.rb', line 915 def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/sources", params: params, opts: opts) end |
.field_remappings ⇒ Object
1006 1007 1008 |
# File 'lib/stripe/resources/source.rb', line 1006 def self.field_remappings @field_remappings = {} end |
.inner_class_types ⇒ Object
976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 |
# File 'lib/stripe/resources/source.rb', line 976 def self.inner_class_types @inner_class_types = { ach_credit_transfer: AchCreditTransfer, ach_debit: AchDebit, acss_debit: AcssDebit, alipay: Alipay, au_becs_debit: AuBecsDebit, bancontact: Bancontact, card: Card, card_present: CardPresent, code_verification: CodeVerification, eps: Eps, giropay: Giropay, ideal: Ideal, klarna: Klarna, multibanco: Multibanco, owner: Owner, p24: P24, paypal: Paypal, receiver: Receiver, redirect: Redirect, sepa_credit_transfer: SepaCreditTransfer, sepa_debit: SepaDebit, sofort: Sofort, source_order: SourceOrder, three_d_secure: ThreeDSecure, wechat: Wechat, } 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.
922 923 924 925 926 927 928 929 |
# File 'lib/stripe/resources/source.rb', line 922 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.
942 943 944 945 946 947 948 949 |
# File 'lib/stripe/resources/source.rb', line 942 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
951 952 953 954 955 956 957 958 959 960 961 962 963 |
# File 'lib/stripe/resources/source.rb', line 951 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
965 966 967 968 969 970 971 972 |
# File 'lib/stripe/resources/source.rb', line 965 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.
932 933 934 935 936 937 938 939 |
# File 'lib/stripe/resources/source.rb', line 932 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 |