Class: Stripe::SetupIntent
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::SetupIntent
- Extended by:
- APIOperations::Create, APIOperations::List
- Includes:
- APIOperations::Save
- Defined in:
- lib/stripe/resources/setup_intent.rb
Overview
A SetupIntent guides you through the process of setting up and saving a customer's payment credentials for future payments. For example, you can use a SetupIntent to set up and save your customer's card without immediately collecting a payment. Later, you can use PaymentIntents to drive the payment flow.
Create a SetupIntent when you're ready to collect your customer's payment credentials. Don't maintain long-lived, unconfirmed SetupIntents because they might not be valid. The SetupIntent transitions through multiple statuses as it guides you through the setup process.
Successful SetupIntents result in payment credentials that are optimized for future payments. For example, cardholders in certain regions might need to be run through Strong Customer Authentication during payment method collection to streamline later off-session payments. If you use the SetupIntent with a Customer, it automatically attaches the resulting payment method to that Customer after successful setup. We recommend using SetupIntents or setup_future_usage on PaymentIntents to save payment methods to prevent saving invalid or unoptimized payment methods.
By using SetupIntents, you can reduce friction for your customers, even as regulations change over time.
Related guide: Setup Intents API
Defined Under Namespace
Classes: AutomaticPaymentMethods, LastSetupError, ManagedPayments, NextAction, PaymentMethodConfigurationDetails, PaymentMethodOptions, Redaction
Constant Summary collapse
- OBJECT_NAME =
"setup_intent"
Constants inherited from StripeObject
Stripe::StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary collapse
-
#allowed_payment_method_types ⇒ Object
readonly
The list of payment method types to allow for this SetupIntent.
-
#application ⇒ Object
readonly
ID of the Connect application that created the SetupIntent.
-
#attach_to_self ⇒ Object
readonly
If present, the SetupIntent's payment method will be attached to the in-context Stripe Account.
-
#automatic_payment_methods ⇒ Object
readonly
Settings for dynamic payment methods compatible with this Setup Intent.
-
#cancellation_reason ⇒ Object
readonly
Reason for cancellation of this SetupIntent, one of
abandoned,requested_by_customer, orduplicate. -
#client_secret ⇒ Object
readonly
The client secret of this SetupIntent.
-
#created ⇒ Object
readonly
Time at which the object was created.
-
#customer ⇒ Object
readonly
ID of the Customer this SetupIntent belongs to, if one exists.
-
#customer_account ⇒ Object
readonly
ID of the Account this SetupIntent belongs to, if one exists.
-
#description ⇒ Object
readonly
An arbitrary string attached to the object.
-
#excluded_payment_method_types ⇒ Object
readonly
Payment method types that are excluded from this SetupIntent.
-
#flow_directions ⇒ Object
readonly
Indicates the directions of money movement for which this payment method is intended to be used.
-
#id ⇒ Object
readonly
Unique identifier for the object.
-
#last_setup_error ⇒ Object
readonly
The error encountered in the previous SetupIntent confirmation.
-
#latest_attempt ⇒ Object
readonly
The most recent SetupAttempt for this SetupIntent.
-
#livemode ⇒ Object
readonly
If the object exists in live mode, the value is
true. -
#managed_payments ⇒ Object
readonly
Attribute for field managed_payments.
-
#mandate ⇒ Object
readonly
ID of the multi use Mandate generated by the SetupIntent.
-
#metadata ⇒ Object
readonly
Set of key-value pairs that you can attach to an object.
-
#next_action ⇒ Object
readonly
If present, this property tells you what actions you need to take in order for your customer to continue payment setup.
-
#object ⇒ Object
readonly
String representing the object's type.
-
#on_behalf_of ⇒ Object
readonly
The account (if any) for which the setup is intended.
-
#payment_method ⇒ Object
readonly
ID of the payment method used with this SetupIntent.
-
#payment_method_configuration_details ⇒ Object
readonly
Information about the payment method configuration used for this Setup Intent.
-
#payment_method_options ⇒ Object
readonly
Payment method-specific configuration for this SetupIntent.
-
#payment_method_types ⇒ Object
readonly
The list of payment method types (e.g. card) that this SetupIntent is allowed to set up.
-
#redaction ⇒ Object
readonly
Redaction status of this SetupIntent.
-
#single_use_mandate ⇒ Object
readonly
ID of the single_use Mandate generated by the SetupIntent.
-
#status ⇒ Object
readonly
Status of this SetupIntent, one of
requires_payment_method,requires_confirmation,requires_action,processing,canceled, orsucceeded. -
#usage ⇒ Object
readonly
Indicates how the payment method is intended to be used in the future.
Attributes inherited from APIResource
Attributes inherited from StripeObject
Class Method Summary collapse
-
.cancel(intent, params = {}, opts = {}) ⇒ Object
You can cancel a SetupIntent object when it's in one of these statuses: requires_payment_method, requires_confirmation, or requires_action.
-
.confirm(intent, params = {}, opts = {}) ⇒ Object
Confirm that your customer intends to set up the current or provided payment method.
-
.create(params = {}, opts = {}) ⇒ Object
Creates a SetupIntent object.
- .field_remappings ⇒ Object
- .inner_class_types ⇒ Object
-
.list(params = {}, opts = {}) ⇒ Object
Returns a list of SetupIntents.
- .object_name ⇒ Object
-
.update(intent, params = {}, opts = {}) ⇒ Object
Updates a SetupIntent object.
-
.verify_microdeposits(intent, params = {}, opts = {}) ⇒ Object
Verifies microdeposits on a SetupIntent object.
Instance Method Summary collapse
-
#cancel(params = {}, opts = {}) ⇒ Object
You can cancel a SetupIntent object when it's in one of these statuses: requires_payment_method, requires_confirmation, or requires_action.
-
#confirm(params = {}, opts = {}) ⇒ Object
Confirm that your customer intends to set up the current or provided payment method.
-
#verify_microdeposits(params = {}, opts = {}) ⇒ Object
Verifies microdeposits on a SetupIntent object.
Methods included from APIOperations::Create
Methods included from APIOperations::List
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
#allowed_payment_method_types ⇒ Object (readonly)
The list of payment method types to allow for this SetupIntent. Stripe will only use methods in this list when determining the payment methods to offer.
780 781 782 |
# File 'lib/stripe/resources/setup_intent.rb', line 780 def allowed_payment_method_types @allowed_payment_method_types end |
#application ⇒ Object (readonly)
ID of the Connect application that created the SetupIntent.
782 783 784 |
# File 'lib/stripe/resources/setup_intent.rb', line 782 def application @application end |
#attach_to_self ⇒ Object (readonly)
If present, the SetupIntent's payment method will be attached to the in-context Stripe Account.
It can only be used for this Stripe Account’s own money movement flows like InboundTransfer and OutboundTransfers. It cannot be set to true when setting up a PaymentMethod for a Customer, and defaults to false when attaching a PaymentMethod to a Customer.
786 787 788 |
# File 'lib/stripe/resources/setup_intent.rb', line 786 def attach_to_self @attach_to_self end |
#automatic_payment_methods ⇒ Object (readonly)
Settings for dynamic payment methods compatible with this Setup Intent
788 789 790 |
# File 'lib/stripe/resources/setup_intent.rb', line 788 def automatic_payment_methods @automatic_payment_methods end |
#cancellation_reason ⇒ Object (readonly)
Reason for cancellation of this SetupIntent, one of abandoned, requested_by_customer, or duplicate.
790 791 792 |
# File 'lib/stripe/resources/setup_intent.rb', line 790 def cancellation_reason @cancellation_reason end |
#client_secret ⇒ Object (readonly)
The client secret of this SetupIntent. Used for client-side retrieval using a publishable key.
The client secret can be used to complete payment setup from your frontend. It should not be stored, logged, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret.
794 795 796 |
# File 'lib/stripe/resources/setup_intent.rb', line 794 def client_secret @client_secret end |
#created ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
796 797 798 |
# File 'lib/stripe/resources/setup_intent.rb', line 796 def created @created end |
#customer ⇒ Object (readonly)
ID of the Customer this SetupIntent belongs to, if one exists.
If present, the SetupIntent's payment method will be attached to the Customer on successful setup. Payment methods attached to other Customers cannot be used with this SetupIntent.
800 801 802 |
# File 'lib/stripe/resources/setup_intent.rb', line 800 def customer @customer end |
#customer_account ⇒ Object (readonly)
ID of the Account this SetupIntent belongs to, if one exists.
If present, the SetupIntent's payment method will be attached to the Account on successful setup. Payment methods attached to other Accounts cannot be used with this SetupIntent.
804 805 806 |
# File 'lib/stripe/resources/setup_intent.rb', line 804 def customer_account @customer_account end |
#description ⇒ Object (readonly)
An arbitrary string attached to the object. Often useful for displaying to users.
806 807 808 |
# File 'lib/stripe/resources/setup_intent.rb', line 806 def description @description end |
#excluded_payment_method_types ⇒ Object (readonly)
Payment method types that are excluded from this SetupIntent.
808 809 810 |
# File 'lib/stripe/resources/setup_intent.rb', line 808 def excluded_payment_method_types @excluded_payment_method_types end |
#flow_directions ⇒ Object (readonly)
Indicates the directions of money movement for which this payment method is intended to be used.
Include inbound if you intend to use the payment method as the origin to pull funds from. Include outbound if you intend to use the payment method as the destination to send funds to. You can include both if you intend to use the payment method for both purposes.
812 813 814 |
# File 'lib/stripe/resources/setup_intent.rb', line 812 def flow_directions @flow_directions end |
#id ⇒ Object (readonly)
Unique identifier for the object.
814 815 816 |
# File 'lib/stripe/resources/setup_intent.rb', line 814 def id @id end |
#last_setup_error ⇒ Object (readonly)
The error encountered in the previous SetupIntent confirmation.
816 817 818 |
# File 'lib/stripe/resources/setup_intent.rb', line 816 def last_setup_error @last_setup_error end |
#latest_attempt ⇒ Object (readonly)
The most recent SetupAttempt for this SetupIntent.
818 819 820 |
# File 'lib/stripe/resources/setup_intent.rb', line 818 def latest_attempt @latest_attempt 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.
820 821 822 |
# File 'lib/stripe/resources/setup_intent.rb', line 820 def livemode @livemode end |
#managed_payments ⇒ Object (readonly)
Attribute for field managed_payments
822 823 824 |
# File 'lib/stripe/resources/setup_intent.rb', line 822 def managed_payments @managed_payments end |
#mandate ⇒ Object (readonly)
ID of the multi use Mandate generated by the SetupIntent.
824 825 826 |
# File 'lib/stripe/resources/setup_intent.rb', line 824 def mandate @mandate end |
#metadata ⇒ Object (readonly)
Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
826 827 828 |
# File 'lib/stripe/resources/setup_intent.rb', line 826 def @metadata end |
#next_action ⇒ Object (readonly)
If present, this property tells you what actions you need to take in order for your customer to continue payment setup.
828 829 830 |
# File 'lib/stripe/resources/setup_intent.rb', line 828 def next_action @next_action end |
#object ⇒ Object (readonly)
String representing the object's type. Objects of the same type share the same value.
830 831 832 |
# File 'lib/stripe/resources/setup_intent.rb', line 830 def object @object end |
#on_behalf_of ⇒ Object (readonly)
The account (if any) for which the setup is intended.
832 833 834 |
# File 'lib/stripe/resources/setup_intent.rb', line 832 def on_behalf_of @on_behalf_of end |
#payment_method ⇒ Object (readonly)
ID of the payment method used with this SetupIntent. If the payment method is card_present and isn't a digital wallet, then the generated_card associated with the latest_attempt is attached to the Customer instead.
834 835 836 |
# File 'lib/stripe/resources/setup_intent.rb', line 834 def payment_method @payment_method end |
#payment_method_configuration_details ⇒ Object (readonly)
Information about the payment method configuration used for this Setup Intent.
836 837 838 |
# File 'lib/stripe/resources/setup_intent.rb', line 836 def payment_method_configuration_details @payment_method_configuration_details end |
#payment_method_options ⇒ Object (readonly)
Payment method-specific configuration for this SetupIntent.
838 839 840 |
# File 'lib/stripe/resources/setup_intent.rb', line 838 def @payment_method_options end |
#payment_method_types ⇒ Object (readonly)
The list of payment method types (e.g. card) that this SetupIntent is allowed to set up. A list of valid payment method types can be found here.
840 841 842 |
# File 'lib/stripe/resources/setup_intent.rb', line 840 def payment_method_types @payment_method_types end |
#redaction ⇒ Object (readonly)
Redaction status of this SetupIntent. If the SetupIntent isn't redacted, this field is null.
842 843 844 |
# File 'lib/stripe/resources/setup_intent.rb', line 842 def redaction @redaction end |
#single_use_mandate ⇒ Object (readonly)
ID of the single_use Mandate generated by the SetupIntent.
844 845 846 |
# File 'lib/stripe/resources/setup_intent.rb', line 844 def single_use_mandate @single_use_mandate end |
#status ⇒ Object (readonly)
Status of this SetupIntent, one of requires_payment_method, requires_confirmation, requires_action, processing, canceled, or succeeded.
846 847 848 |
# File 'lib/stripe/resources/setup_intent.rb', line 846 def status @status end |
#usage ⇒ Object (readonly)
Indicates how the payment method is intended to be used in the future.
Use on_session if you intend to only reuse the payment method when the customer is in your checkout flow. Use off_session if your customer may or may not be in your checkout flow. If not provided, this value defaults to off_session.
850 851 852 |
# File 'lib/stripe/resources/setup_intent.rb', line 850 def usage @usage end |
Class Method Details
.cancel(intent, params = {}, opts = {}) ⇒ Object
You can cancel a SetupIntent object when it's in one of these statuses: requires_payment_method, requires_confirmation, or requires_action.
After you cancel it, setup is abandoned and any operations on the SetupIntent fail with an error. You can't cancel the SetupIntent for a Checkout Session. Expire the Checkout Session instead.
867 868 869 870 871 872 873 874 |
# File 'lib/stripe/resources/setup_intent.rb', line 867 def self.cancel(intent, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/setup_intents/%<intent>s/cancel", { intent: CGI.escape(intent) }), params: params, opts: opts ) end |
.confirm(intent, params = {}, opts = {}) ⇒ Object
Confirm that your customer intends to set up the current or provided payment method. For example, you would confirm a SetupIntent when a customer hits the “Save” button on a payment method management page on your website.
If the selected payment method does not require any additional steps from the customer, the SetupIntent will transition to the succeeded status.
Otherwise, it will transition to the requires_action status and suggest additional actions via next_action. If setup fails, the SetupIntent will transition to the requires_payment_method status or the canceled status if the confirmation limit is reached.
913 914 915 916 917 918 919 920 |
# File 'lib/stripe/resources/setup_intent.rb', line 913 def self.confirm(intent, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/setup_intents/%<intent>s/confirm", { intent: CGI.escape(intent) }), params: params, opts: opts ) end |
.create(params = {}, opts = {}) ⇒ Object
Creates a SetupIntent object.
After you create the SetupIntent, attach a payment method and confirm it to collect any required permissions to charge the payment method later.
926 927 928 |
# File 'lib/stripe/resources/setup_intent.rb', line 926 def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/setup_intents", params: params, opts: opts) end |
.field_remappings ⇒ Object
977 978 979 |
# File 'lib/stripe/resources/setup_intent.rb', line 977 def self.field_remappings @field_remappings = {} end |
.inner_class_types ⇒ Object
965 966 967 968 969 970 971 972 973 974 975 |
# File 'lib/stripe/resources/setup_intent.rb', line 965 def self.inner_class_types @inner_class_types = { automatic_payment_methods: AutomaticPaymentMethods, last_setup_error: LastSetupError, managed_payments: ManagedPayments, next_action: NextAction, payment_method_configuration_details: PaymentMethodConfigurationDetails, payment_method_options: PaymentMethodOptions, redaction: Redaction, } end |
.list(params = {}, opts = {}) ⇒ Object
Returns a list of SetupIntents.
931 932 933 |
# File 'lib/stripe/resources/setup_intent.rb', line 931 def self.list(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/setup_intents", params: params, opts: opts) end |
.object_name ⇒ Object
32 33 34 |
# File 'lib/stripe/resources/setup_intent.rb', line 32 def self.object_name "setup_intent" end |
.update(intent, params = {}, opts = {}) ⇒ Object
Updates a SetupIntent object.
936 937 938 939 940 941 942 943 |
# File 'lib/stripe/resources/setup_intent.rb', line 936 def self.update(intent, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/setup_intents/%<intent>s", { intent: CGI.escape(intent) }), params: params, opts: opts ) end |
.verify_microdeposits(intent, params = {}, opts = {}) ⇒ Object
Verifies microdeposits on a SetupIntent object.
956 957 958 959 960 961 962 963 |
# File 'lib/stripe/resources/setup_intent.rb', line 956 def self.verify_microdeposits(intent, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/setup_intents/%<intent>s/verify_microdeposits", { intent: CGI.escape(intent) }), params: params, opts: opts ) end |
Instance Method Details
#cancel(params = {}, opts = {}) ⇒ Object
You can cancel a SetupIntent object when it's in one of these statuses: requires_payment_method, requires_confirmation, or requires_action.
After you cancel it, setup is abandoned and any operations on the SetupIntent fail with an error. You can't cancel the SetupIntent for a Checkout Session. Expire the Checkout Session instead.
855 856 857 858 859 860 861 862 |
# File 'lib/stripe/resources/setup_intent.rb', line 855 def cancel(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/setup_intents/%<intent>s/cancel", { intent: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#confirm(params = {}, opts = {}) ⇒ Object
Confirm that your customer intends to set up the current or provided payment method. For example, you would confirm a SetupIntent when a customer hits the “Save” button on a payment method management page on your website.
If the selected payment method does not require any additional steps from the customer, the SetupIntent will transition to the succeeded status.
Otherwise, it will transition to the requires_action status and suggest additional actions via next_action. If setup fails, the SetupIntent will transition to the requires_payment_method status or the canceled status if the confirmation limit is reached.
890 891 892 893 894 895 896 897 |
# File 'lib/stripe/resources/setup_intent.rb', line 890 def confirm(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/setup_intents/%<intent>s/confirm", { intent: CGI.escape(self["id"]) }), params: params, opts: opts ) end |
#verify_microdeposits(params = {}, opts = {}) ⇒ Object
Verifies microdeposits on a SetupIntent object.
946 947 948 949 950 951 952 953 |
# File 'lib/stripe/resources/setup_intent.rb', line 946 def verify_microdeposits(params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/setup_intents/%<intent>s/verify_microdeposits", { intent: CGI.escape(self["id"]) }), params: params, opts: opts ) end |