View Source Stripe.Token (Striped v0.2.0)

Tokenization is the process Stripe uses to collect sensitive card or bank account details, or personally identifiable information (PII), directly from your customers in a secure manner. A token representing this information is returned to your server to use. You should use our recommended payments integrations to perform this process client-side. This ensures that no sensitive card data touches your server, and allows your integration to operate in a PCI-compliant way.

If you cannot use client-side tokenization, you can also create tokens using the API with either your publishable or secret API key. Keep in mind that if your integration uses this method, you are responsible for any PCI compliance that may be required, and you must keep your secret API key safe. Unlike with client-side tokenization, your customer's information is not sent directly to Stripe, so we cannot determine how it is handled or stored.

Tokens cannot be stored or used more than once. To store card or bank account information for later use, you can create Customer objects or Custom accounts. Note that Radar, our integrated solution for automatic fraud protection, performs best with integrations that use client-side tokenization.

Related guide: Accept a payment

Link to this section Summary

Types

Information for the account this token will represent.

The individual's verification document information.

Information for the person this token will represent.

Information for the person this token will represent.

Information for the person this token will represent.

The bank account this token will represent.

Information for the account this token will represent.

Documents that may be submitted to satisfy various informational requests.

The updated CVC value this token will represent.

The individual's verification document information.

Information for the person this token will represent.

Information for the account this token will represent.

Information about the company or business.

Documents that may be submitted to satisfy various informational requests.

Information for the person this token will represent.

The PII this token will represent.

Information about the person represented by the account.

Information for the person this token will represent.

t()

The token type.

Information for the person this token will represent.

Documents that may be submitted to satisfy various informational requests.

Functions

Creates a single-use token that represents a bank account’s details.This token can be used with any API method in place of a bank account dictionary. This token can be used only once, by attaching it to a Custom account.

Retrieves the token with the given ID.

Link to this section Types

@type account() :: %{
  optional(:business_type) =>
    :company | :government_entity | :individual | :non_profit,
  :company => company(),
  :individual => individual(),
  optional(:tos_shown_and_accepted) => :boolean
}

Information for the account this token will represent.

@type additional_document() :: %{
  optional(:back) => :string,
  optional(:front) => :string
}

The individual's verification document information.

@type address() :: %{
  optional(:city) => :string,
  optional(:country) => :string,
  optional(:line1) => :string,
  optional(:line2) => :string,
  optional(:postal_code) => :string,
  optional(:state) => :string
}

Information for the person this token will represent.

@type address_kana() :: %{
  optional(:city) => :string,
  optional(:country) => :string,
  optional(:line1) => :string,
  optional(:line2) => :string,
  optional(:postal_code) => :string,
  optional(:state) => :string,
  optional(:town) => :string
}

Information for the person this token will represent.

@type address_kanji() :: %{
  optional(:city) => :string,
  optional(:country) => :string,
  optional(:line1) => :string,
  optional(:line2) => :string,
  optional(:postal_code) => :string,
  optional(:state) => :string,
  optional(:town) => :string
}

Information for the person this token will represent.

@type bank_account() :: %{
  optional(:account_holder_name) => :string,
  optional(:account_holder_type) => :company | :individual,
  optional(:account_number) => :string,
  optional(:account_type) => :checking | :futsu | :savings | :toza,
  optional(:country) => :string,
  optional(:currency) => :string,
  optional(:routing_number) => :string
}

The bank account this token will represent.

@type card() :: %{
  optional(:address_city) => :string,
  optional(:address_country) => :string,
  optional(:address_line1) => :string,
  optional(:address_line2) => :string,
  optional(:address_state) => :string,
  optional(:address_zip) => :string,
  optional(:currency) => :string,
  optional(:cvc) => :string,
  :exp_month => :string,
  :exp_year => :string,
  optional(:name) => :string,
  number: :string
}
@type company() :: %{
  :address => address(),
  :address_kana => address_kana(),
  :address_kanji => address_kanji(),
  optional(:directors_provided) => :boolean,
  optional(:executives_provided) => :boolean,
  optional(:name) => :string,
  optional(:name_kana) => :string,
  optional(:name_kanji) => :string,
  optional(:owners_provided) => :boolean,
  :ownership_declaration => ownership_declaration(),
  optional(:ownership_declaration_shown_and_signed) => :boolean,
  optional(:phone) => :string,
  optional(:registration_number) => :string,
  optional(:structure) =>
    :free_zone_establishment
    | :free_zone_llc
    | :government_instrumentality
    | :governmental_unit
    | :incorporated_non_profit
    | :limited_liability_partnership
    | :llc
    | :multi_member_llc
    | :private_company
    | :private_corporation
    | :private_partnership
    | :public_company
    | :public_corporation
    | :public_partnership
    | :single_member_llc
    | :sole_establishment
    | :sole_proprietorship
    | :tax_exempt_government_instrumentality
    | :unincorporated_association
    | :unincorporated_non_profit,
  optional(:tax_id) => :string,
  optional(:tax_id_registrar) => :string,
  optional(:vat_id) => :string,
  verification: verification()
}

Information for the account this token will represent.

Link to this type

company_authorization()

View Source
@type company_authorization() :: %{optional(:files) => [:string]}

Documents that may be submitted to satisfy various informational requests.

@type cvc_update() :: %{optional(:cvc) => :string}

The updated CVC value this token will represent.

@type document() :: %{optional(:back) => :string, optional(:front) => :string}

The individual's verification document information.

@type documents() :: %{
  company_authorization: company_authorization(),
  passport: passport(),
  visa: visa()
}

Information for the person this token will represent.

@type individual() :: %{
  :address => address(),
  :address_kana => address_kana(),
  :address_kanji => address_kanji(),
  optional(:dob) => :object | :string,
  optional(:email) => :string,
  optional(:first_name) => :string,
  optional(:first_name_kana) => :string,
  optional(:first_name_kanji) => :string,
  optional(:full_name_aliases) => [:string] | :string,
  optional(:gender) => :string,
  optional(:id_number) => :string,
  optional(:id_number_secondary) => :string,
  optional(:last_name) => :string,
  optional(:last_name_kana) => :string,
  optional(:last_name_kanji) => :string,
  optional(:maiden_name) => :string,
  optional(:metadata) => :object | :string,
  optional(:phone) => :string,
  optional(:political_exposure) => :existing | :none,
  :registered_address => registered_address(),
  optional(:ssn_last_4) => :string,
  verification: verification()
}

Information for the account this token will represent.

Link to this type

ownership_declaration()

View Source
@type ownership_declaration() :: %{
  optional(:date) => :integer,
  optional(:ip) => :string,
  optional(:user_agent) => :string
}

Information about the company or business.

@type passport() :: %{optional(:files) => [:string]}

Documents that may be submitted to satisfy various informational requests.

@type person() :: %{
  :address => address(),
  :address_kana => address_kana(),
  :address_kanji => address_kanji(),
  optional(:dob) => :object | :string,
  :documents => documents(),
  optional(:email) => :string,
  optional(:first_name) => :string,
  optional(:first_name_kana) => :string,
  optional(:first_name_kanji) => :string,
  optional(:full_name_aliases) => [:string] | :string,
  optional(:gender) => :string,
  optional(:id_number) => :string,
  optional(:id_number_secondary) => :string,
  optional(:last_name) => :string,
  optional(:last_name_kana) => :string,
  optional(:last_name_kanji) => :string,
  optional(:maiden_name) => :string,
  optional(:metadata) => :object | :string,
  optional(:nationality) => :string,
  optional(:phone) => :string,
  optional(:political_exposure) => :string,
  :registered_address => registered_address(),
  :relationship => relationship(),
  optional(:ssn_last_4) => :string,
  verification: verification()
}

Information for the person this token will represent.

@type pii() :: %{optional(:id_number) => :string}

The PII this token will represent.

@type registered_address() :: %{
  optional(:city) => :string,
  optional(:country) => :string,
  optional(:line1) => :string,
  optional(:line2) => :string,
  optional(:postal_code) => :string,
  optional(:state) => :string
}

Information about the person represented by the account.

@type relationship() :: %{
  optional(:director) => :boolean,
  optional(:executive) => :boolean,
  optional(:owner) => :boolean,
  optional(:percent_ownership) => :number | :string,
  optional(:representative) => :boolean,
  optional(:title) => :string
}

Information for the person this token will represent.

@type t() :: %Stripe.Token{
  bank_account: Stripe.BankAccount.t(),
  card: Stripe.Card.t(),
  client_ip: binary() | nil,
  created: integer(),
  id: binary(),
  livemode: boolean(),
  object: binary(),
  type: binary(),
  used: boolean()
}

The token type.

  • bank_account
  • card
  • client_ip IP address of the client that generated the token.
  • created Time at which the object was created. Measured in seconds since the Unix epoch.
  • id Unique identifier for the object.
  • livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode.
  • object String representing the object's type. Objects of the same type share the same value.
  • type Type of the token: account, bank_account, card, or pii.
  • used Whether this token has already been used (tokens can be used only once).
@type verification() :: %{
  additional_document: additional_document(),
  document: document()
}

Information for the person this token will represent.

@type visa() :: %{optional(:files) => [:string]}

Documents that may be submitted to satisfy various informational requests.

Link to this section Functions

Link to this function

create(client, params \\ %{})

View Source
@spec create(
  client :: term(),
  params :: %{
    optional(:account) => account(),
    optional(:bank_account) => bank_account(),
    optional(:card) => card() | :string,
    optional(:customer) => :string,
    optional(:cvc_update) => cvc_update(),
    optional(:expand) => [:string],
    optional(:person) => person(),
    optional(:pii) => pii()
  }
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Creates a single-use token that represents a bank account’s details.This token can be used with any API method in place of a bank account dictionary. This token can be used only once, by attaching it to a Custom account.

#### Details * Method: `post` * Path: `/v1/tokens`

Link to this function

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

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

Retrieves the token with the given ID.

Details

  • Method: get
  • Path: /v1/tokens/{token}