View Source Stripe.Source (stripity_stripe v3.1.1)

Source objects allow you to accept a variety of payment methods. They represent a customer's payment instrument, and can be used with the Stripe API just like a Card object: once chargeable, they can be charged, or can be attached to customers.

Stripe doesn't recommend using the deprecated Sources API. We recommend that you adopt the PaymentMethods API. This newer API provides access to our latest features and payment method types.

Related guides: Sources API and Sources & Customers.

Link to this section Summary

Types

The parameters required to notify Stripe of a mandate acceptance or refusal by the customer.

Owner's address.

Information about a mandate possibility attached to a source object (generally for bank debits) as well as its acceptance status.

The parameters required to store a mandate accepted offline. Should only be set if mandate[type] is offline

The parameters required to store a mandate accepted online. Should only be set if mandate[type] is online

Information about the owner of the payment instrument that may be used or required by particular source types.

Optional parameters for the receiver flow. Can be set only if the source is a receiver (flow is receiver).

Parameters required for the redirect flow. Required if the source is authenticated by a redirect (flow is redirect).

Shipping address for the order. Required if any of the SKUs are for products that have shippable set to true.

Information about the items and shipping associated with the source. Required for transactional credit (for example Klarna) sources before you can charge it.

t()

The source type.

Functions

Creates a new source object.

Delete a specified source for a given customer.

Retrieves an existing source object. Supply the unique source ID from a source creation request and Stripe will return the corresponding up-to-date source object information.

List source transactions for a given source.

Updates the specified source by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

Link to this section Types

@type acceptance() :: %{
  optional(:date) => integer(),
  optional(:ip) => binary(),
  optional(:offline) => offline(),
  optional(:online) => online(),
  optional(:status) => :accepted | :pending | :refused | :revoked,
  optional(:type) => :offline | :online,
  optional(:user_agent) => binary()
}

The parameters required to notify Stripe of a mandate acceptance or refusal by the customer.

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

Owner's address.

@type items() :: %{
  optional(:amount) => integer(),
  optional(:currency) => binary(),
  optional(:description) => binary(),
  optional(:parent) => binary(),
  optional(:quantity) => integer(),
  optional(:type) => :discount | :shipping | :sku | :tax
}
@type mandate() :: %{
  optional(:acceptance) => acceptance(),
  optional(:amount) => integer() | binary(),
  optional(:currency) => binary(),
  optional(:interval) => :one_time | :scheduled | :variable,
  optional(:notification_method) =>
    :deprecated_none | :email | :manual | :none | :stripe_email
}

Information about a mandate possibility attached to a source object (generally for bank debits) as well as its acceptance status.

@type offline() :: %{optional(:contact_email) => binary()}

The parameters required to store a mandate accepted offline. Should only be set if mandate[type] is offline

@type online() :: %{
  optional(:date) => integer(),
  optional(:ip) => binary(),
  optional(:user_agent) => binary()
}

The parameters required to store a mandate accepted online. Should only be set if mandate[type] is online

@type owner() :: %{
  optional(:address) => address(),
  optional(:email) => binary(),
  optional(:name) => binary(),
  optional(:phone) => binary()
}

Information about the owner of the payment instrument that may be used or required by particular source types.

@type receiver() :: %{optional(:refund_attributes_method) => :email | :manual | :none}

Optional parameters for the receiver flow. Can be set only if the source is a receiver (flow is receiver).

@type redirect() :: %{optional(:return_url) => binary()}

Parameters required for the redirect flow. Required if the source is authenticated by a redirect (flow is redirect).

@type shipping() :: %{
  optional(:address) => address(),
  optional(:carrier) => binary(),
  optional(:name) => binary(),
  optional(:phone) => binary(),
  optional(:tracking_number) => binary()
}

Shipping address for the order. Required if any of the SKUs are for products that have shippable set to true.

@type source_order() :: %{
  optional(:items) => [items()],
  optional(:shipping) => shipping()
}

Information about the items and shipping associated with the source. Required for transactional credit (for example Klarna) sources before you can charge it.

@type t() :: %Stripe.Source{
  ach_credit_transfer: term(),
  ach_debit: term(),
  acss_debit: term(),
  alipay: term(),
  amount: integer() | nil,
  au_becs_debit: term(),
  bancontact: term(),
  card: term(),
  card_present: term(),
  client_secret: binary(),
  code_verification: term(),
  created: integer(),
  currency: binary() | nil,
  customer: binary(),
  eps: term(),
  flow: binary(),
  giropay: term(),
  id: binary(),
  ideal: term(),
  klarna: term(),
  livemode: boolean(),
  metadata: term() | nil,
  multibanco: term(),
  object: binary(),
  owner: term() | nil,
  p24: term(),
  receiver: term(),
  redirect: term(),
  sepa_credit_transfer: term(),
  sepa_debit: term(),
  sofort: term(),
  source_order: term(),
  statement_descriptor: binary() | nil,
  status: binary(),
  three_d_secure: term(),
  type: binary(),
  usage: binary() | nil,
  wechat: term()
}

The source type.

  • ach_credit_transfer
  • ach_debit
  • acss_debit
  • alipay
  • amount A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the total amount associated with the source. This is the amount for which the source will be chargeable once ready. Required for single_use sources.
  • au_becs_debit
  • bancontact
  • card
  • card_present
  • client_secret The client secret of the source. Used for client-side retrieval using a publishable key.
  • code_verification
  • created Time at which the object was created. Measured in seconds since the Unix epoch.
  • currency Three-letter ISO code for the currency associated with the source. This is the currency for which the source will be chargeable once ready. Required for single_use sources.
  • customer The ID of the customer to which this source is attached. This will not be present when the source has not been attached to a customer.
  • eps
  • flow The authentication flow of the source. flow is one of redirect, receiver, code_verification, none.
  • giropay
  • id Unique identifier for the object.
  • ideal
  • klarna
  • 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.
  • multibanco
  • object String representing the object's type. Objects of the same type share the same value.
  • owner Information about the owner of the payment instrument that may be used or required by particular source types.
  • p24
  • receiver
  • redirect
  • sepa_credit_transfer
  • sepa_debit
  • sofort
  • source_order
  • statement_descriptor Extra information about a source. This will appear on your customer's statement every time you charge the source.
  • status The status of the source, one of canceled, chargeable, consumed, failed, or pending. Only chargeable sources can be used to create a charge.
  • three_d_secure
  • type The type of the source. The type is a payment method, one of ach_credit_transfer, ach_debit, alipay, bancontact, card, card_present, eps, giropay, ideal, multibanco, klarna, p24, sepa_debit, sofort, three_d_secure, or wechat. An additional hash is included on the source with a name matching this value. It contains additional information specific to the payment method used.
  • usage Either reusable or single_use. Whether this source should be reusable or not. Some source types may or may not be reusable by construction, while others may leave the option at creation. If an incompatible value is passed, an error will be returned.
  • wechat

Link to this section Functions

Link to this function

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

View Source
@spec create(
  params :: %{
    optional(:amount) => integer(),
    optional(:currency) => binary(),
    optional(:customer) => binary(),
    optional(:expand) => [binary()],
    optional(:flow) => :code_verification | :none | :receiver | :redirect,
    optional(:mandate) => mandate(),
    optional(:metadata) => %{optional(binary()) => binary()},
    optional(:original_source) => binary(),
    optional(:owner) => owner(),
    optional(:receiver) => receiver(),
    optional(:redirect) => redirect(),
    optional(:source_order) => source_order(),
    optional(:statement_descriptor) => binary(),
    optional(:token) => binary(),
    optional(:type) => binary(),
    optional(:usage) => :reusable | :single_use
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Creates a new source object.

Details

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

detach(customer, id, params \\ %{}, opts \\ [])

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

Delete a specified source for a given customer.

Details

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

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

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

Retrieves an existing source object. Supply the unique source ID from a source creation request and Stripe will return the corresponding up-to-date source object information.

Details

  • Method: get
  • Path: /v1/sources/{source}
Link to this function

source_transactions(source, params \\ %{}, opts \\ [])

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

List source transactions for a given source.

Details

  • Method: get
  • Path: /v1/sources/{source}/source_transactions
Link to this function

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

View Source
@spec update(
  source :: binary(),
  params :: %{
    optional(:amount) => integer(),
    optional(:expand) => [binary()],
    optional(:mandate) => mandate(),
    optional(:metadata) => %{optional(binary()) => binary()} | binary(),
    optional(:owner) => owner(),
    optional(:source_order) => source_order()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Updates the specified source by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

This request accepts the metadata and owner as arguments. It is also possible to update type specific information for selected payment methods. Please refer to our payment method guides for more detail.

Details

  • Method: post
  • Path: /v1/sources/{source}
Link to this function

verify(source, params \\ %{}, opts \\ [])

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

Verify a given source.

Details

  • Method: post
  • Path: /v1/sources/{source}/verify