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](stripe.com/docs/api#payment_intents) 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](docs.stripe.com/payments/intents#intent-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](stripe.com/guides/strong-customer-authentication) might need to be run through [Strong Customer Authentication](docs.stripe.com/strong-customer-authentication) during payment method collection to streamline later [off-session payments](docs.stripe.com/payments/setup-intents). If you use the SetupIntent with a [Customer](stripe.com/docs/api#setup_intent_object-customer), it automatically attaches the resulting payment method to that Customer after successful setup. We recommend using SetupIntents or [setup_future_usage](stripe.com/docs/api#payment_intent_object-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](docs.stripe.com/payments/setup-intents)
Defined Under Namespace
Classes: AutomaticPaymentMethods, CancelParams, ConfirmParams, CreateParams, LastSetupError, ListParams, NextAction, PaymentMethodConfigurationDetails, PaymentMethodOptions, RetrieveParams, UpdateParams, VerifyMicrodepositsParams
Constant Summary collapse
- OBJECT_NAME =
"setup_intent"
Constants inherited from StripeObject
Stripe::StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary collapse
-
#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`, or `duplicate`.
-
#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.
-
#description ⇒ Object
readonly
An arbitrary string attached to the object.
-
#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
Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.
-
#mandate ⇒ Object
readonly
ID of the multi use Mandate generated by the SetupIntent.
-
#metadata ⇒ Object
readonly
Set of [key-value pairs](stripe.com/docs/api/metadata) 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](stripe.com/docs/api/payment_method_configurations) 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.
-
#single_use_mandate ⇒ Object
readonly
ID of the single_use Mandate generated by the SetupIntent.
-
#status ⇒ Object
readonly
[Status](stripe.com/docs/payments/intents#intent-statuses) of this SetupIntent, one of ‘requires_payment_method`, `requires_confirmation`, `requires_action`, `processing`, `canceled`, or `succeeded`.
-
#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.
-
.list(params = {}, opts = {}) ⇒ Object
Returns a list of SetupIntents.
- .object_name ⇒ Object
-
.update(id, 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
#==, #[], #[]=, 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
#application ⇒ Object (readonly)
ID of the Connect application that created the SetupIntent.
4323 4324 4325 |
# File 'lib/stripe/resources/setup_intent.rb', line 4323 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.
4328 4329 4330 |
# File 'lib/stripe/resources/setup_intent.rb', line 4328 def attach_to_self @attach_to_self end |
#automatic_payment_methods ⇒ Object (readonly)
Settings for dynamic payment methods compatible with this Setup Intent
4331 4332 4333 |
# File 'lib/stripe/resources/setup_intent.rb', line 4331 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`.
4334 4335 4336 |
# File 'lib/stripe/resources/setup_intent.rb', line 4334 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.
4339 4340 4341 |
# File 'lib/stripe/resources/setup_intent.rb', line 4339 def client_secret @client_secret end |
#created ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
4342 4343 4344 |
# File 'lib/stripe/resources/setup_intent.rb', line 4342 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.
4347 4348 4349 |
# File 'lib/stripe/resources/setup_intent.rb', line 4347 def customer @customer end |
#description ⇒ Object (readonly)
An arbitrary string attached to the object. Often useful for displaying to users.
4350 4351 4352 |
# File 'lib/stripe/resources/setup_intent.rb', line 4350 def description @description 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.
4355 4356 4357 |
# File 'lib/stripe/resources/setup_intent.rb', line 4355 def flow_directions @flow_directions end |
#id ⇒ Object (readonly)
Unique identifier for the object.
4358 4359 4360 |
# File 'lib/stripe/resources/setup_intent.rb', line 4358 def id @id end |
#last_setup_error ⇒ Object (readonly)
The error encountered in the previous SetupIntent confirmation.
4361 4362 4363 |
# File 'lib/stripe/resources/setup_intent.rb', line 4361 def last_setup_error @last_setup_error end |
#latest_attempt ⇒ Object (readonly)
The most recent SetupAttempt for this SetupIntent.
4364 4365 4366 |
# File 'lib/stripe/resources/setup_intent.rb', line 4364 def latest_attempt @latest_attempt 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.
4367 4368 4369 |
# File 'lib/stripe/resources/setup_intent.rb', line 4367 def livemode @livemode end |
#mandate ⇒ Object (readonly)
ID of the multi use Mandate generated by the SetupIntent.
4370 4371 4372 |
# File 'lib/stripe/resources/setup_intent.rb', line 4370 def mandate @mandate 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.
4373 4374 4375 |
# File 'lib/stripe/resources/setup_intent.rb', line 4373 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.
4376 4377 4378 |
# File 'lib/stripe/resources/setup_intent.rb', line 4376 def next_action @next_action end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
4379 4380 4381 |
# File 'lib/stripe/resources/setup_intent.rb', line 4379 def object @object end |
#on_behalf_of ⇒ Object (readonly)
The account (if any) for which the setup is intended.
4382 4383 4384 |
# File 'lib/stripe/resources/setup_intent.rb', line 4382 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](docs.stripe.com/api/setup_attempts/object#setup_attempt_object-payment_method_details-card_present-generated_card) associated with the ‘latest_attempt` is attached to the Customer instead.
4385 4386 4387 |
# File 'lib/stripe/resources/setup_intent.rb', line 4385 def payment_method @payment_method end |
#payment_method_configuration_details ⇒ Object (readonly)
Information about the [payment method configuration](stripe.com/docs/api/payment_method_configurations) used for this Setup Intent.
4388 4389 4390 |
# File 'lib/stripe/resources/setup_intent.rb', line 4388 def payment_method_configuration_details @payment_method_configuration_details end |
#payment_method_options ⇒ Object (readonly)
Payment method-specific configuration for this SetupIntent.
4391 4392 4393 |
# File 'lib/stripe/resources/setup_intent.rb', line 4391 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.
4394 4395 4396 |
# File 'lib/stripe/resources/setup_intent.rb', line 4394 def payment_method_types @payment_method_types end |
#single_use_mandate ⇒ Object (readonly)
ID of the single_use Mandate generated by the SetupIntent.
4397 4398 4399 |
# File 'lib/stripe/resources/setup_intent.rb', line 4397 def single_use_mandate @single_use_mandate end |
#status ⇒ Object (readonly)
[Status](stripe.com/docs/payments/intents#intent-statuses) of this SetupIntent, one of ‘requires_payment_method`, `requires_confirmation`, `requires_action`, `processing`, `canceled`, or `succeeded`.
4400 4401 4402 |
# File 'lib/stripe/resources/setup_intent.rb', line 4400 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`.
4405 4406 4407 |
# File 'lib/stripe/resources/setup_intent.rb', line 4405 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](stripe.com/docs/api/checkout/sessions/expire) instead.
4422 4423 4424 4425 4426 4427 4428 4429 |
# File 'lib/stripe/resources/setup_intent.rb', line 4422 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.
4468 4469 4470 4471 4472 4473 4474 4475 |
# File 'lib/stripe/resources/setup_intent.rb', line 4468 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](stripe.com/docs/api/setup_intents/confirm) it to collect any required permissions to charge the payment method later.
4481 4482 4483 |
# File 'lib/stripe/resources/setup_intent.rb', line 4481 def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/setup_intents", params: params, opts: opts) end |
.list(params = {}, opts = {}) ⇒ Object
Returns a list of SetupIntents.
4486 4487 4488 |
# File 'lib/stripe/resources/setup_intent.rb', line 4486 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(id, params = {}, opts = {}) ⇒ Object
Updates a SetupIntent object.
4491 4492 4493 4494 4495 4496 4497 4498 |
# File 'lib/stripe/resources/setup_intent.rb', line 4491 def self.update(id, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/setup_intents/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts ) end |
.verify_microdeposits(intent, params = {}, opts = {}) ⇒ Object
Verifies microdeposits on a SetupIntent object.
4511 4512 4513 4514 4515 4516 4517 4518 |
# File 'lib/stripe/resources/setup_intent.rb', line 4511 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](stripe.com/docs/api/checkout/sessions/expire) instead.
4410 4411 4412 4413 4414 4415 4416 4417 |
# File 'lib/stripe/resources/setup_intent.rb', line 4410 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.
4445 4446 4447 4448 4449 4450 4451 4452 |
# File 'lib/stripe/resources/setup_intent.rb', line 4445 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.
4501 4502 4503 4504 4505 4506 4507 4508 |
# File 'lib/stripe/resources/setup_intent.rb', line 4501 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 |