View Source Stripe.Customer (Striped v0.5.0) (generated)

This object represents a customer of your business. It lets you create recurring charges and track payments that belong to the same customer.

Related guide: Save a card during payment.

Link to this section Summary

Types

Additional parameters for bank_transfer funding types

Balance information and default balance settings for this customer.

Configuration for eu_bank_transfer funding type.

Default invoice settings for this customer.

Settings controlling the behavior of the customer's cash balance, such as reconciliation of funds received.

t()

The customer type.

Tax details about the customer.

Functions

Returns a list of transactions that updated the customer’s balances.

Creates a new customer object.

Retrieve funding instructions for a customer cash balance. If funding instructions do not yet exist for the customer, newfunding instructions will be created. If funding instructions have already been created for a given customer, the same funding instructions will be retrieved. In other words, we will return the same funding instructions each time.

Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer.

Removes the currently applied discount on a customer.

Create an incoming testmode bank transfe.

Returns a list of your customers. The customers are returned sorted by creation date, with the most recent customers appearing first.

Returns a list of PaymentMethods for a given Custome.

Retrieves a PaymentMethod object for a given Customer.

Search for customers you’ve previously created using Stripe’s Search Query Language.Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up to an hour behind during outages. Search functionality is not available to merchants in India.

Updates the specified customer by setting the values of the parameters passed. Any parameters not provided will be left unchanged. For example, if you pass the source parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges in the future. When you update a customer to a new valid card source by passing the source parameter: for each of the customer’s current subscriptions, if the subscription bills automatically and is in the past_due state, then the latest open invoice for the subscription with automatic collection enabled will be retried. This retry will not count as an automatic retry, and will not affect the next regularly scheduled payment for the invoice. Changing the default_source for a customer will not trigger this behavior.

Link to this section Types

@type address() :: %{
  optional(:city) => binary(),
  optional(:country) => binary(),
  optional(:line1) => binary(),
  optional(:line2) => binary(),
  optional(:postal_code) => binary(),
  optional(:state) => binary()
}
@type bank_transfer() :: %{
  optional(:eu_bank_transfer) => eu_bank_transfer(),
  optional(:requested_address_types) => [:iban | :sort_code | :spei | :zengin],
  optional(:type) =>
    :eu_bank_transfer
    | :gb_bank_transfer
    | :jp_bank_transfer
    | :mx_bank_transfer
}

Additional parameters for bank_transfer funding types

@type cash_balance() :: %{optional(:settings) => settings()}

Balance information and default balance settings for this customer.

@type created() :: %{
  optional(:gt) => integer(),
  optional(:gte) => integer(),
  optional(:lt) => integer(),
  optional(:lte) => integer()
}
@type custom_fields() :: %{optional(:name) => binary(), optional(:value) => binary()}
@type eu_bank_transfer() :: %{optional(:country) => binary()}

Configuration for eu_bank_transfer funding type.

@type invoice_settings() :: %{
  optional(:custom_fields) => [custom_fields()] | binary(),
  optional(:default_payment_method) => binary(),
  optional(:footer) => binary(),
  optional(:rendering_options) => rendering_options() | binary()
}

Default invoice settings for this customer.

@type rendering_options() :: %{
  optional(:amount_tax_display) => :exclude_tax | :include_inclusive_tax
}
@type settings() :: %{optional(:reconciliation_mode) => :automatic | :manual}

Settings controlling the behavior of the customer's cash balance, such as reconciliation of funds received.

@type shipping() :: %{
  optional(:address) => address(),
  optional(:name) => binary(),
  optional(:phone) => binary()
}
@type t() :: %Stripe.Customer{
  address: term() | nil,
  balance: integer(),
  cash_balance: Stripe.CashBalance.t() | nil,
  created: integer(),
  currency: binary() | nil,
  default_source: (binary() | Stripe.PaymentSource.t()) | nil,
  delinquent: boolean() | nil,
  description: binary() | nil,
  discount: term() | nil,
  email: binary() | nil,
  id: binary(),
  invoice_credit_balance: term(),
  invoice_prefix: binary() | nil,
  invoice_settings: term(),
  livemode: boolean(),
  metadata: term(),
  name: binary() | nil,
  next_invoice_sequence: integer(),
  object: binary(),
  phone: binary() | nil,
  preferred_locales: term() | nil,
  shipping: term() | nil,
  sources: term(),
  subscriptions: term(),
  tax: term(),
  tax_exempt: binary() | nil,
  tax_ids: term(),
  test_clock: (binary() | Stripe.TestHelpers.TestClock.t()) | nil
}

The customer type.

  • address The customer's address.
  • balance Current balance, if any, being stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that will be added to their next invoice. The balance does not refer to any unpaid invoices; it solely takes into account amounts that have yet to be successfully applied to any invoice. This balance is only taken into account as invoices are finalized.
  • cash_balance The current funds being held by Stripe on behalf of the customer. These funds can be applied towards payment intents with source "cash_balance". The settings[reconciliation_mode] field describes whether these funds are applied to such payment intents manually or automatically.
  • created Time at which the object was created. Measured in seconds since the Unix epoch.
  • currency Three-letter ISO code for the currency the customer can be charged in for recurring billing purposes.
  • default_source ID of the default payment source for the customer.

If you are using payment methods created via the PaymentMethods API, see the invoice_settings.default_payment_method field instead.

  • delinquent When the customer's latest invoice is billed by charging automatically, delinquent is true if the invoice's latest charge failed. When the customer's latest invoice is billed by sending an invoice, delinquent is true if the invoice isn't paid by its due date.

If an invoice is marked uncollectible by dunning, delinquent doesn't get reset to false.

  • description An arbitrary string attached to the object. Often useful for displaying to users.
  • discount Describes the current discount active on the customer, if there is one.
  • email The customer's email address.
  • id Unique identifier for the object.
  • invoice_credit_balance The current multi-currency balances, if any, being stored on the customer. If positive in a currency, the customer has a credit to apply to their next invoice denominated in that currency. If negative, the customer has an amount owed that will be added to their next invoice denominated in that currency. These balances do not refer to any unpaid invoices. They solely track amounts that have yet to be successfully applied to any invoice. A balance in a particular currency is only applied to any invoice as an invoice in that currency is finalized.
  • invoice_prefix The prefix for the customer used to generate unique invoice numbers.
  • invoice_settings
  • livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode.
  • 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.
  • name The customer's full name or business name.
  • next_invoice_sequence The suffix of the customer's next invoice number, e.g., 0001.
  • object String representing the object's type. Objects of the same type share the same value.
  • phone The customer's phone number.
  • preferred_locales The customer's preferred locales (languages), ordered by preference.
  • shipping Mailing and shipping address for the customer. Appears on invoices emailed to this customer.
  • sources The customer's payment sources, if any.
  • subscriptions The customer's current subscriptions, if any.
  • tax
  • tax_exempt Describes the customer's tax exemption status. One of none, exempt, or reverse. When set to reverse, invoice and receipt PDFs include the text "Reverse charge".
  • tax_ids The customer's tax IDs.
  • test_clock ID of the test clock this customer belongs to.
@type tax() :: %{optional(:ip_address) => binary() | binary()}

Tax details about the customer.

@type tax_id_data() :: %{
  optional(:type) =>
    :ae_trn
    | :au_abn
    | :au_arn
    | :bg_uic
    | :br_cnpj
    | :br_cpf
    | :ca_bn
    | :ca_gst_hst
    | :ca_pst_bc
    | :ca_pst_mb
    | :ca_pst_sk
    | :ca_qst
    | :ch_vat
    | :cl_tin
    | :eg_tin
    | :es_cif
    | :eu_oss_vat
    | :eu_vat
    | :gb_vat
    | :ge_vat
    | :hk_br
    | :hu_tin
    | :id_npwp
    | :il_vat
    | :in_gst
    | :is_vat
    | :jp_cn
    | :jp_rn
    | :jp_trn
    | :ke_pin
    | :kr_brn
    | :li_uid
    | :mx_rfc
    | :my_frp
    | :my_itn
    | :my_sst
    | :no_vat
    | :nz_gst
    | :ph_tin
    | :ru_inn
    | :ru_kpp
    | :sa_vat
    | :sg_gst
    | :sg_uen
    | :si_tin
    | :th_vat
    | :tr_tin
    | :tw_vat
    | :ua_vat
    | :us_ein
    | :za_vat,
  optional(:value) => binary()
}

Link to this section Functions

Link to this function

balance_transactions(client, customer, params \\ %{}, opts \\ [])

View Source
@spec balance_transactions(
  client :: Stripe.t(),
  customer :: binary(),
  params :: %{
    optional(:ending_before) => binary(),
    optional(:expand) => [binary()],
    optional(:limit) => integer(),
    optional(:starting_after) => binary()
  },
  opts :: Keyword.t()
) ::
  {:ok, Stripe.List.t(Stripe.CustomerBalanceTransaction.t())}
  | {:error, Stripe.ApiErrors.t()}
  | {:error, term()}

Returns a list of transactions that updated the customer’s balances.

Details

  • Method: get
  • Path: /v1/customers/{customer}/balance_transactions
Link to this function

create(client, params \\ %{}, opts \\ [])

View Source
@spec create(
  client :: Stripe.t(),
  params :: %{
    optional(:address) => address() | binary(),
    optional(:balance) => integer(),
    optional(:cash_balance) => cash_balance(),
    optional(:coupon) => binary(),
    optional(:description) => binary(),
    optional(:email) => binary(),
    optional(:expand) => [binary()],
    optional(:invoice_prefix) => binary(),
    optional(:invoice_settings) => invoice_settings(),
    optional(:metadata) => %{optional(binary()) => binary()} | binary(),
    optional(:name) => binary(),
    optional(:next_invoice_sequence) => integer(),
    optional(:payment_method) => binary(),
    optional(:phone) => binary(),
    optional(:preferred_locales) => [binary()],
    optional(:promotion_code) => binary(),
    optional(:shipping) => shipping() | binary(),
    optional(:source) => binary(),
    optional(:tax) => tax(),
    optional(:tax_exempt) => :exempt | :none | :reverse,
    optional(:tax_id_data) => [tax_id_data()],
    optional(:test_clock) => binary(),
    optional(:validate) => boolean()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Creates a new customer object.

Details

  • Method: post
  • Path: /v1/customers
Link to this function

create_funding_instructions(client, customer, params \\ %{}, opts \\ [])

View Source
@spec create_funding_instructions(
  client :: Stripe.t(),
  customer :: binary(),
  params :: %{
    optional(:bank_transfer) => bank_transfer(),
    optional(:currency) => binary(),
    optional(:expand) => [binary()],
    optional(:funding_type) => :bank_transfer
  },
  opts :: Keyword.t()
) ::
  {:ok, Stripe.FundingInstructions.t()}
  | {:error, Stripe.ApiErrors.t()}
  | {:error, term()}

Retrieve funding instructions for a customer cash balance. If funding instructions do not yet exist for the customer, newfunding instructions will be created. If funding instructions have already been created for a given customer, the same funding instructions will be retrieved. In other words, we will return the same funding instructions each time.

Details

  • Method: post
  • Path: /v1/customers/{customer}/funding_instructions
Link to this function

delete(client, customer, opts \\ [])

View Source
@spec delete(client :: Stripe.t(), customer :: binary(), opts :: Keyword.t()) ::
  {:ok, Stripe.DeletedCustomer.t()}
  | {:error, Stripe.ApiErrors.t()}
  | {:error, term()}

Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer.

Details

  • Method: delete
  • Path: /v1/customers/{customer}
Link to this function

delete_discount(client, customer, opts \\ [])

View Source
@spec delete_discount(client :: Stripe.t(), customer :: binary(), opts :: Keyword.t()) ::
  {:ok, Stripe.DeletedDiscount.t()}
  | {:error, Stripe.ApiErrors.t()}
  | {:error, term()}

Removes the currently applied discount on a customer.

Details

  • Method: delete
  • Path: /v1/customers/{customer}/discount
Link to this function

fund_cash_balance(client, customer, params \\ %{}, opts \\ [])

View Source
@spec fund_cash_balance(
  client :: Stripe.t(),
  customer :: binary(),
  params :: %{
    optional(:amount) => integer(),
    optional(:currency) => binary(),
    optional(:expand) => [binary()],
    optional(:reference) => binary()
  },
  opts :: Keyword.t()
) ::
  {:ok, Stripe.CustomerCashBalanceTransaction.t()}
  | {:error, Stripe.ApiErrors.t()}
  | {:error, term()}

Create an incoming testmode bank transfe.

Details

  • Method: post
  • Path: /v1/test_helpers/customers/{customer}/fund_cash_balance
Link to this function

list(client, params \\ %{}, opts \\ [])

View Source
@spec list(
  client :: Stripe.t(),
  params :: %{
    optional(:created) => created() | integer(),
    optional(:email) => binary(),
    optional(:ending_before) => binary(),
    optional(:expand) => [binary()],
    optional(:limit) => integer(),
    optional(:starting_after) => binary(),
    optional(:test_clock) => binary()
  },
  opts :: Keyword.t()
) ::
  {:ok, Stripe.List.t(t())} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Returns a list of your customers. The customers are returned sorted by creation date, with the most recent customers appearing first.

Details

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

list_payment_methods(client, customer, params \\ %{}, opts \\ [])

View Source
@spec list_payment_methods(
  client :: Stripe.t(),
  customer :: binary(),
  params :: %{
    optional(:ending_before) => binary(),
    optional(:expand) => [binary()],
    optional(:limit) => integer(),
    optional(:starting_after) => binary(),
    optional(:type) =>
      :acss_debit
      | :affirm
      | :afterpay_clearpay
      | :alipay
      | :au_becs_debit
      | :bacs_debit
      | :bancontact
      | :blik
      | :boleto
      | :card
      | :card_present
      | :customer_balance
      | :eps
      | :fpx
      | :giropay
      | :grabpay
      | :ideal
      | :klarna
      | :konbini
      | :link
      | :oxxo
      | :p24
      | :paynow
      | :pix
      | :promptpay
      | :sepa_debit
      | :sofort
      | :us_bank_account
      | :wechat_pay
  },
  opts :: Keyword.t()
) ::
  {:ok, Stripe.List.t(Stripe.PaymentMethod.t())}
  | {:error, Stripe.ApiErrors.t()}
  | {:error, term()}

Returns a list of PaymentMethods for a given Custome.

Details

  • Method: get
  • Path: /v1/customers/{customer}/payment_methods
Link to this function

retrieve(client, customer, params \\ %{}, opts \\ [])

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

Retrieves a Customer object.

Details

  • Method: get
  • Path: /v1/customers/{customer}
Link to this function

retrieve_payment_method(client, customer, payment_method, params \\ %{}, opts \\ [])

View Source
@spec retrieve_payment_method(
  client :: Stripe.t(),
  customer :: binary(),
  payment_method :: binary(),
  params :: %{optional(:expand) => [binary()]},
  opts :: Keyword.t()
) ::
  {:ok, Stripe.PaymentMethod.t()}
  | {:error, Stripe.ApiErrors.t()}
  | {:error, term()}

Retrieves a PaymentMethod object for a given Customer.

Details

  • Method: get
  • Path: /v1/customers/{customer}/payment_methods/{payment_method}
Link to this function

search(client, params \\ %{}, opts \\ [])

View Source
@spec search(
  client :: Stripe.t(),
  params :: %{
    optional(:expand) => [binary()],
    optional(:limit) => integer(),
    optional(:page) => binary(),
    optional(:query) => binary()
  },
  opts :: Keyword.t()
) ::
  {:ok, Stripe.SearchResult.t(t())}
  | {:error, Stripe.ApiErrors.t()}
  | {:error, term()}

Search for customers you’ve previously created using Stripe’s Search Query Language.Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up to an hour behind during outages. Search functionality is not available to merchants in India.

Details

  • Method: get
  • Path: /v1/customers/search
Link to this function

update(client, customer, params \\ %{}, opts \\ [])

View Source
@spec update(
  client :: Stripe.t(),
  customer :: binary(),
  params :: %{
    optional(:address) => address() | binary(),
    optional(:balance) => integer(),
    optional(:cash_balance) => cash_balance(),
    optional(:coupon) => binary(),
    optional(:default_source) => binary(),
    optional(:description) => binary(),
    optional(:email) => binary(),
    optional(:expand) => [binary()],
    optional(:invoice_prefix) => binary(),
    optional(:invoice_settings) => invoice_settings(),
    optional(:metadata) => %{optional(binary()) => binary()} | binary(),
    optional(:name) => binary(),
    optional(:next_invoice_sequence) => integer(),
    optional(:phone) => binary(),
    optional(:preferred_locales) => [binary()],
    optional(:promotion_code) => binary(),
    optional(:shipping) => shipping() | binary(),
    optional(:source) => binary(),
    optional(:tax) => tax(),
    optional(:tax_exempt) => :exempt | :none | :reverse,
    optional(:validate) => boolean()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Updates the specified customer by setting the values of the parameters passed. Any parameters not provided will be left unchanged. For example, if you pass the source parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges in the future. When you update a customer to a new valid card source by passing the source parameter: for each of the customer’s current subscriptions, if the subscription bills automatically and is in the past_due state, then the latest open invoice for the subscription with automatic collection enabled will be retried. This retry will not count as an automatic retry, and will not affect the next regularly scheduled payment for the invoice. Changing the default_source for a customer will not trigger this behavior.

This request accepts mostly the same arguments as the customer creation call.

Details

  • Method: post
  • Path: /v1/customers/{customer}