View Source Stripe.PaymentMethod (Striped v0.1.0)

PaymentMethod objects represent your customer's payment instruments. You can use them with PaymentIntents to collect payments or save them to Customer objects to store instrument details for future payments.

Related guides: Payment Methods and More Payment Scenarios.

Link to this section Summary

Types

t()

The payment_method type.

Functions

Attaches a PaymentMethod object to a Customer.

Creates a PaymentMethod object. Read the Stripe.js reference to learn how to create PaymentMethods via Stripe.js.

Detaches a PaymentMethod object from a Customer. After a PaymentMethod is detached, it can no longer be used for a payment or re-attached to a Customer.

Returns a list of PaymentMethods attached to the StripeAccount. For listing a customer’s payment methods, you should use List a Customer’s PaymentMethods

Retrieves a PaymentMethod object attached to the StripeAccount. To retrieve a payment method attached to a Customer, you should use Retrieve a Customer’s PaymentMethods

Updates a PaymentMethod object. A PaymentMethod must be attached a customer to be updated.

Link to this section Types

@type t() :: %Stripe.PaymentMethod{
  acss_debit: term(),
  affirm: term(),
  afterpay_clearpay: term(),
  alipay: term(),
  au_becs_debit: term(),
  bacs_debit: term(),
  bancontact: term(),
  billing_details: term(),
  blik: term(),
  boleto: term(),
  card: term(),
  card_present: term(),
  created: integer(),
  customer: (binary() | Stripe.Customer.t()) | nil,
  customer_balance: term(),
  eps: term(),
  fpx: term(),
  giropay: term(),
  grabpay: term(),
  id: binary(),
  ideal: term(),
  interac_present: term(),
  klarna: term(),
  konbini: term(),
  link: term(),
  livemode: boolean(),
  metadata: term() | nil,
  object: binary(),
  oxxo: term(),
  p24: term(),
  paynow: term(),
  pix: term(),
  promptpay: term(),
  radar_options: term(),
  sepa_debit: term(),
  sofort: term(),
  type: binary(),
  us_bank_account: term(),
  wechat_pay: term()
}

The payment_method type.

  • pix
  • fpx
  • affirm
  • livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode.
  • acss_debit
  • bacs_debit
  • alipay
  • giropay
  • ideal
  • card
  • radar_options
  • 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.
  • link
  • promptpay
  • oxxo
  • interac_present
  • customer The ID of the Customer to which this PaymentMethod is saved. This will not be set when the PaymentMethod has not been saved to a Customer.
  • us_bank_account
  • boleto
  • object String representing the object's type. Objects of the same type share the same value.
  • konbini
  • billing_details
  • blik
  • wechat_pay
  • sofort
  • p24
  • created Time at which the object was created. Measured in seconds since the Unix epoch.
  • afterpay_clearpay
  • type The type of the PaymentMethod. An additional hash is included on the PaymentMethod with a name matching this value. It contains additional information specific to the PaymentMethod type.
  • grabpay
  • bancontact
  • au_becs_debit
  • customer_balance
  • card_present
  • sepa_debit
  • klarna
  • paynow
  • id Unique identifier for the object.
  • eps

Link to this section Functions

Link to this function

attach(client, payment_method, params \\ %{})

View Source
@spec attach(client :: term(), payment_method :: binary(), params :: map()) ::
  {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Attaches a PaymentMethod object to a Customer.

To attach a new PaymentMethod to a customer for future payments, we recommend you use a SetupIntentor a PaymentIntent with setup_future_usage. These approaches will perform any necessary steps to set up the PaymentMethod for future payments. Using the /v1/payment_methods/:id/attach endpoint without first using a SetupIntent or PaymentIntent with setup_future_usage does not optimize the PaymentMethod for future use, which makes later declines and payment friction more likely. See Optimizing cards for future payments for more information about setting up future payments.

To use this PaymentMethod as the default for invoice or subscription payments,set invoice_settings.default_payment_method, on the Customer to the PaymentMethod’s ID.

#### Details * Method: `post` * Path: `/v1/payment_methods/{payment_method}/attach`

Link to this function

create(client, params \\ %{})

View Source
@spec create(client :: term(), params :: map()) ::
  {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Creates a PaymentMethod object. Read the Stripe.js reference to learn how to create PaymentMethods via Stripe.js.

Instead of creating a PaymentMethod directly, we recommend using the PaymentIntents API to accept a payment immediately or the SetupIntent API to collect payment method details ahead of a future payment.

Details

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

detach(client, payment_method, params \\ %{})

View Source
@spec detach(client :: term(), payment_method :: binary(), params :: map()) ::
  {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Detaches a PaymentMethod object from a Customer. After a PaymentMethod is detached, it can no longer be used for a payment or re-attached to a Customer.

Details

  • Method: post
  • Path: /v1/payment_methods/{payment_method}/detach
Link to this function

list(client, params \\ %{})

View Source
@spec list(client :: term(), params :: map()) ::
  {:ok, Stripe.List.t(t())} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Returns a list of PaymentMethods attached to the StripeAccount. For listing a customer’s payment methods, you should use List a Customer’s PaymentMethods

Details

  • Method: get
  • Path: /v1/payment_methods

Query parameters

  • :customer string
  • :ending_before string
  • :expand array of: string
  • :limit integer
  • :starting_after string
  • :type (Required) string
Link to this function

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

View Source
@spec retrieve(client :: term(), payment_method :: binary(), params :: map()) ::
  {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Retrieves a PaymentMethod object attached to the StripeAccount. To retrieve a payment method attached to a Customer, you should use Retrieve a Customer’s PaymentMethods

Details

  • Method: get
  • Path: /v1/payment_methods/{payment_method}

Query parameters

  • :expand array of: string
Link to this function

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

View Source
@spec update(client :: term(), payment_method :: binary(), params :: map()) ::
  {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Updates a PaymentMethod object. A PaymentMethod must be attached a customer to be updated.

Details

  • Method: post
  • Path: /v1/payment_methods/{payment_method}