View Source Stripe.SetupIntent (Striped v0.1.0)
A SetupIntent guides you through the process of setting up and saving a customer's payment credentials for future payments. For example, you could 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 as soon as you're ready to collect your customer's payment credentials. Do not maintain long-lived, unconfirmed SetupIntents as they may no longer be valid. The SetupIntent then 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 may need to be run through Strong Customer Authentication at the time of payment method collection in order to streamline later off-session payments. If the SetupIntent is used with a Customer, upon success, it will automatically attach the resulting payment method to that Customer. We recommend using SetupIntents or setup_future_usage on PaymentIntents to save payment methods in order to prevent saving invalid or unoptimized payment methods.
By using SetupIntents, you ensure that your customers experience the minimum set of required friction, even as regulations change over time.
Related guide: Setup Intents API.
Link to this section Summary
Functions
A SetupIntent object can be canceled when it is in one of these statuses: requires_payment_method
, requires_confirmation
, or requires_action
.
Confirm that your customer intends to set up the current orprovided 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.
Creates a SetupIntent object.
Returns a list of SetupIntents.
Retrieves the details of a SetupIntent that has previously been created.
Updates a SetupIntent object.
Verifies microdeposits on a SetupIntent object.
Link to this section Types
@type t() :: %Stripe.SetupIntent{ application: (binary() | term()) | nil, attach_to_self: boolean(), cancellation_reason: binary() | nil, client_secret: binary() | nil, created: integer(), customer: (binary() | Stripe.Customer.t() | Stripe.DeletedCustomer.t()) | nil, description: binary() | nil, flow_directions: term() | nil, id: binary(), last_setup_error: Stripe.ApiErrors.t() | nil, latest_attempt: (binary() | Stripe.SetupAttempt.t()) | nil, livemode: boolean(), mandate: (binary() | Stripe.Mandate.t()) | nil, metadata: term() | nil, next_action: term() | nil, object: binary(), on_behalf_of: (binary() | Stripe.Account.t()) | nil, payment_method: (binary() | Stripe.PaymentMethod.t()) | nil, payment_method_options: term() | nil, payment_method_types: term(), single_use_mandate: (binary() | Stripe.Mandate.t()) | nil, status: binary(), usage: binary() }
The setup_intent
type.
application
ID of the Connect application that created the SetupIntent.attach_to_self
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.
cancellation_reason
Reason for cancellation of this SetupIntent, one ofabandoned
,requested_by_customer
, orduplicate
.client_secret
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.
created
Time at which the object was created. Measured in seconds since the Unix epoch.customer
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.
description
An arbitrary string attached to the object. Often useful for displaying to users.flow_directions
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.
id
Unique identifier for the object.last_setup_error
The error encountered in the previous SetupIntent confirmation.latest_attempt
The most recent SetupAttempt for this SetupIntent.livemode
Has the valuetrue
if the object exists in live mode or the valuefalse
if the object exists in test mode.mandate
ID of the multi use Mandate generated by the SetupIntent.metadata
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.next_action
If present, this property tells you what actions you need to take in order for your customer to continue payment setup.object
String representing the object's type. Objects of the same type share the same value.on_behalf_of
The account (if any) for which the setup is intended.payment_method
ID of the payment method used with this SetupIntent.payment_method_options
Payment-method-specific configuration for this SetupIntent.payment_method_types
The list of payment method types (e.g. card) that this SetupIntent is allowed to set up.single_use_mandate
ID of the single_use Mandate generated by the SetupIntent.status
Status of this SetupIntent, one ofrequires_payment_method
,requires_confirmation
,requires_action
,processing
,canceled
, orsucceeded
.usage
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
.
Link to this section Functions
@spec cancel(client :: term(), intent :: binary(), params :: map()) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
A SetupIntent object can be canceled when it is in one of these statuses: requires_payment_method
, requires_confirmation
, or requires_action
.
Once canceled, setup is abandoned and any operations on the SetupIntent will fail with an error.
Details
- Method:
post
- Path:
/v1/setup_intents/{intent}/cancel
@spec confirm(client :: term(), intent :: binary(), params :: map()) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
Confirm that your customer intends to set up the current orprovided 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 additionalsteps from the customer, the SetupIntent will transition to the
succeeded
status.
Otherwise, it will transition to the requires_action
status andsuggest additional actions via next_action
. If setup fails,
the SetupIntent will transition to the
requires_payment_method
status.
@spec create(client :: term(), params :: map()) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
Creates a SetupIntent object.
After the SetupIntent is created, attach a payment method and confirmto collect any required permissions to charge the payment method later.
#### Details * Method: `post` * Path: `/v1/setup_intents`@spec list(client :: term(), params :: map()) :: {:ok, Stripe.List.t(t())} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
Returns a list of SetupIntents.
Details
- Method:
get
- Path:
/v1/setup_intents
Query parameters
:attach_to_self
boolean:created
any of:- object with (optional) properties:
gt
: integergte
: integerlt
: integerlte
: integer
- integer
- object with (optional) properties:
:customer
string:ending_before
string:expand
array of: string:limit
integer:payment_method
string:starting_after
string
@spec retrieve(client :: term(), intent :: binary(), params :: map()) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
Retrieves the details of a SetupIntent that has previously been created.
Client-side retrieval using a publishable key is allowed when the client_secret
is provided in the query string.
When retrieved with a publishable key, only a subset of properties will be returned. Please refer to the SetupIntent object reference for more details.
Details
- Method:
get
- Path:
/v1/setup_intents/{intent}
Query parameters
:client_secret
string:expand
array of: string
@spec update(client :: term(), intent :: binary(), params :: map()) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
Updates a SetupIntent object.
Details
- Method:
post
- Path:
/v1/setup_intents/{intent}
@spec verify_microdeposits(client :: term(), intent :: binary(), params :: map()) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
Verifies microdeposits on a SetupIntent object.
Details
- Method:
post
- Path:
/v1/setup_intents/{intent}/verify_microdeposits