View Source Stripe.SetupIntent (Striped v0.2.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

Types

Payment-method-specific configuration for this SetupIntent.

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

Payment-method-specific configuration for this SetupIntent.

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

Payment-method-specific configuration for this SetupIntent.

This hash contains details about the Mandate to create. This parameter can only be used with confirm=true.

If this is a klarna PaymentMethod, this hash contains details about the Klarna payment method.

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

If this is a us_bank_account SetupIntent, this sub-hash contains details about the US bank account payment method options.

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

Payment-method-specific configuration for this SetupIntent.

This hash contains details about the Mandate to create. This parameter can only be used with confirm=true.

Configuration for any card setup attempted on this SetupIntent.

If this is a us_bank_account SetupIntent, this sub-hash contains details about the US bank account payment method options.

This hash contains details about the customer acceptance of the Mandate.

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

Payment-method-specific configuration for this SetupIntent.

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

Payment-method-specific configuration for this SetupIntent.

If this hash is populated, this SetupIntent will generate a single_use Mandate on success.

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

t()

The setup_intent type.

Payment-method-specific configuration for this SetupIntent.

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 acss_debit() :: %{
  optional(:currency) => :cad | :usd,
  :mandate_options => mandate_options(),
  optional(:verification_method) => :automatic | :instant | :microdeposits
}

Payment-method-specific configuration for this SetupIntent.

@type au_becs_debit() :: %{
  optional(:account_number) => :string,
  optional(:bsb_number) => :string
}

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

@type bacs_debit() :: %{
  optional(:account_number) => :string,
  optional(:sort_code) => :string
}

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

@type billing_details() :: %{
  optional(:address) => :object | :string,
  optional(:email) => :string | :string,
  optional(:name) => :string,
  optional(:phone) => :string
}

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

@type blik() :: %{optional(:code) => :string}

Payment-method-specific configuration for this SetupIntent.

@type boleto() :: %{optional(:tax_id) => :string}

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

@type card() :: %{
  :mandate_options => mandate_options(),
  optional(:moto) => :boolean,
  optional(:network) =>
    :amex
    | :cartes_bancaires
    | :diners
    | :discover
    | :interac
    | :jcb
    | :mastercard
    | :unionpay
    | :unknown
    | :visa,
  optional(:request_three_d_secure) => :any | :automatic
}

Payment-method-specific configuration for this SetupIntent.

@type customer_acceptance() :: %{
  optional(:accepted_at) => :integer,
  :offline => :object,
  :online => online(),
  optional(:type) => :offline | :online
}

This hash contains details about the Mandate to create. This parameter can only be used with confirm=true.

@type dob() :: %{
  optional(:day) => :integer,
  optional(:month) => :integer,
  optional(:year) => :integer
}

If this is a klarna PaymentMethod, this hash contains details about the Klarna payment method.

@type eps() :: %{
  optional(:bank) =>
    :arzte_und_apotheker_bank
    | :austrian_anadi_bank_ag
    | :bank_austria
    | :bankhaus_carl_spangler
    | :bankhaus_schelhammer_und_schattera_ag
    | :bawag_psk_ag
    | :bks_bank_ag
    | :brull_kallmus_bank_ag
    | :btv_vier_lander_bank
    | :capital_bank_grawe_gruppe_ag
    | :deutsche_bank_ag
    | :dolomitenbank
    | :easybank_ag
    | :erste_bank_und_sparkassen
    | :hypo_alpeadriabank_international_ag
    | :hypo_bank_burgenland_aktiengesellschaft
    | :hypo_noe_lb_fur_niederosterreich_u_wien
    | :hypo_oberosterreich_salzburg_steiermark
    | :hypo_tirol_bank_ag
    | :hypo_vorarlberg_bank_ag
    | :marchfelder_bank
    | :oberbank_ag
    | :raiffeisen_bankengruppe_osterreich
    | :schoellerbank_ag
    | :sparda_bank_wien
    | :volksbank_gruppe
    | :volkskreditbank_ag
    | :vr_bank_braunau
}

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

Link to this type

financial_connections()

View Source
@type financial_connections() :: %{
  optional(:permissions) => [
    :balances | :ownership | :payment_method | :transactions
  ],
  optional(:return_url) => :string
}

If this is a us_bank_account SetupIntent, this sub-hash contains details about the US bank account payment method options.

@type fpx() :: %{
  optional(:account_holder_type) => :company | :individual,
  optional(:bank) =>
    :affin_bank
    | :agrobank
    | :alliance_bank
    | :ambank
    | :bank_islam
    | :bank_muamalat
    | :bank_rakyat
    | :bsn
    | :cimb
    | :deutsche_bank
    | :hong_leong_bank
    | :hsbc
    | :kfh
    | :maybank2e
    | :maybank2u
    | :ocbc
    | :pb_enterprise
    | :public_bank
    | :rhb
    | :standard_chartered
    | :uob
}

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

@type ideal() :: %{
  optional(:bank) =>
    :abn_amro
    | :asn_bank
    | :bunq
    | :handelsbanken
    | :ing
    | :knab
    | :moneyou
    | :rabobank
    | :regiobank
    | :revolut
    | :sns_bank
    | :triodos_bank
    | :van_lanschot
}

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

@type klarna() :: %{dob: dob()}

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

@type link() :: %{optional(:persistent_token) => :string}

Payment-method-specific configuration for this SetupIntent.

@type mandate_data() :: %{customer_acceptance: customer_acceptance()}

This hash contains details about the Mandate to create. This parameter can only be used with confirm=true.

@type mandate_options() :: %{
  optional(:amount) => :integer,
  optional(:amount_type) => :fixed | :maximum,
  optional(:currency) => :string,
  optional(:description) => :string,
  optional(:end_date) => :integer,
  optional(:interval) => :day | :month | :sporadic | :week | :year,
  optional(:interval_count) => :integer,
  optional(:reference) => :string,
  optional(:start_date) => :integer,
  optional(:supported_types) => [:india]
}

Configuration for any card setup attempted on this SetupIntent.

@type networks() :: %{optional(:requested) => [:ach | :us_domestic_wire]}

If this is a us_bank_account SetupIntent, this sub-hash contains details about the US bank account payment method options.

@type online() :: %{
  optional(:ip_address) => :string,
  optional(:user_agent) => :string
}

This hash contains details about the customer acceptance of the Mandate.

@type p24() :: %{
  optional(:bank) =>
    :alior_bank
    | :bank_millennium
    | :bank_nowy_bfg_sa
    | :bank_pekao_sa
    | :banki_spbdzielcze
    | :blik
    | :bnp_paribas
    | :boz
    | :citi_handlowy
    | :credit_agricole
    | :envelobank
    | :etransfer_pocztowy24
    | :getin_bank
    | :ideabank
    | :ing
    | :inteligo
    | :mbank_mtransfer
    | :nest_przelew
    | :noble_pay
    | :pbac_z_ipko
    | :plus_bank
    | :santander_przelew24
    | :tmobile_usbugi_bankowe
    | :toyota_bank
    | :volkswagen_bank
}

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

@type payment_method_data() :: %{
  :acss_debit => acss_debit(),
  :affirm => :object,
  :afterpay_clearpay => :object,
  :alipay => :object,
  :au_becs_debit => au_becs_debit(),
  :bacs_debit => bacs_debit(),
  :bancontact => :object,
  :billing_details => billing_details(),
  :blik => :object,
  :boleto => boleto(),
  :customer_balance => :object,
  :eps => eps(),
  :fpx => fpx(),
  :giropay => :object,
  :grabpay => :object,
  :ideal => ideal(),
  :interac_present => :object,
  :klarna => klarna(),
  :konbini => :object,
  :link => :object,
  :metadata => :object,
  :oxxo => :object,
  :p24 => p24(),
  :paynow => :object,
  :pix => :object,
  :promptpay => :object,
  :radar_options => radar_options(),
  :sepa_debit => sepa_debit(),
  :sofort => sofort(),
  optional(:type) =>
    :acss_debit
    | :affirm
    | :afterpay_clearpay
    | :alipay
    | :au_becs_debit
    | :bacs_debit
    | :bancontact
    | :blik
    | :boleto
    | :customer_balance
    | :eps
    | :fpx
    | :giropay
    | :grabpay
    | :ideal
    | :klarna
    | :konbini
    | :link
    | :oxxo
    | :p24
    | :paynow
    | :pix
    | :promptpay
    | :sepa_debit
    | :sofort
    | :us_bank_account
    | :wechat_pay,
  us_bank_account: us_bank_account(),
  wechat_pay: :object
}

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

Link to this type

payment_method_options()

View Source
@type payment_method_options() :: %{
  acss_debit: acss_debit(),
  blik: blik(),
  card: card(),
  link: link(),
  sepa_debit: sepa_debit(),
  us_bank_account: us_bank_account()
}

Payment-method-specific configuration for this SetupIntent.

@type radar_options() :: %{optional(:session) => :string}

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

@type sepa_debit() :: %{mandate_options: :object}

Payment-method-specific configuration for this SetupIntent.

@type single_use() :: %{optional(:amount) => :integer, optional(:currency) => :string}

If this hash is populated, this SetupIntent will generate a single_use Mandate on success.

@type sofort() :: %{optional(:country) => :AT | :BE | :DE | :ES | :IT | :NL}

When included, this hash creates a PaymentMethod that is set as the payment_method value in the SetupIntent.

@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 of abandoned, requested_by_customer, or duplicate.
  • 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 value true if the object exists in live mode or the value false 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 of requires_payment_method, requires_confirmation, requires_action, processing, canceled, or succeeded.
  • 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.

@type us_bank_account() :: %{
  :financial_connections => financial_connections(),
  :networks => networks(),
  optional(:verification_method) => :automatic | :instant | :microdeposits
}

Payment-method-specific configuration for this SetupIntent.

Link to this section Functions

Link to this function

cancel(client, intent, params \\ %{})

View Source
@spec cancel(
  client :: term(),
  intent :: binary(),
  params :: %{
    optional(:cancellation_reason) =>
      :abandoned | :duplicate | :requested_by_customer,
    optional(:expand) => [:string]
  }
) :: {: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
Link to this function

confirm(client, intent, params \\ %{})

View Source
@spec confirm(
  client :: term(),
  intent :: binary(),
  params :: %{
    optional(:expand) => [:string],
    optional(:mandate_data) => mandate_data() | mandate_data(),
    optional(:payment_method) => :string,
    optional(:payment_method_data) => payment_method_data(),
    optional(:payment_method_options) => payment_method_options(),
    optional(:return_url) => :string
  }
) :: {: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.

#### Details * Method: `post` * Path: `/v1/setup_intents/{intent}/confirm`

Link to this function

create(client, params \\ %{})

View Source
@spec create(
  client :: term(),
  params :: %{
    optional(:attach_to_self) => :boolean,
    optional(:confirm) => :boolean,
    optional(:customer) => :string,
    optional(:description) => :string,
    optional(:expand) => [:string],
    optional(:flow_directions) => [:inbound | :outbound],
    optional(:mandate_data) => mandate_data(),
    :metadata => :object,
    optional(:on_behalf_of) => :string,
    optional(:payment_method) => :string,
    optional(:payment_method_data) => payment_method_data(),
    optional(:payment_method_options) => payment_method_options(),
    optional(:payment_method_types) => [:string],
    optional(:return_url) => :string,
    optional(:single_use) => single_use(),
    optional(:usage) => :off_session | :on_session
  }
) :: {: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`

Link to this function

list(client, params \\ %{})

View Source
@spec list(
  client :: term(),
  params :: %{
    optional(:attach_to_self) => :boolean,
    optional(:created) => :object | :integer,
    optional(:customer) => :string,
    optional(:ending_before) => :string,
    optional(:expand) => [:string],
    optional(:limit) => :integer,
    optional(:payment_method) => :string,
    optional(:starting_after) => :string
  }
) ::
  {:ok, Stripe.List.t(t())} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Returns a list of SetupIntents.

Details

  • Method: get
  • Path: /v1/setup_intents
Link to this function

retrieve(client, intent, params \\ %{})

View Source
@spec retrieve(
  client :: term(),
  intent :: binary(),
  params :: %{
    optional(:client_secret) => :string,
    optional(:expand) => [:string]
  }
) :: {: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}
Link to this function

update(client, intent, params \\ %{})

View Source
@spec update(
  client :: term(),
  intent :: binary(),
  params :: %{
    optional(:attach_to_self) => :boolean,
    optional(:customer) => :string,
    optional(:description) => :string,
    optional(:expand) => [:string],
    optional(:flow_directions) => [:inbound | :outbound],
    optional(:metadata) => :object | :string,
    optional(:payment_method) => :string,
    optional(:payment_method_data) => payment_method_data(),
    optional(:payment_method_options) => payment_method_options(),
    optional(:payment_method_types) => [:string]
  }
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Updates a SetupIntent object.

Details

  • Method: post
  • Path: /v1/setup_intents/{intent}
Link to this function

verify_microdeposits(client, intent, params \\ %{})

View Source
@spec verify_microdeposits(
  client :: term(),
  intent :: binary(),
  params :: %{
    optional(:amounts) => [:integer],
    optional(:descriptor_code) => :string,
    optional(:expand) => [:string]
  }
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Verifies microdeposits on a SetupIntent object.

Details

  • Method: post
  • Path: /v1/setup_intents/{intent}/verify_microdeposits