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
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.
pixfpxaffirmlivemodeHas the valuetrueif the object exists in live mode or the valuefalseif the object exists in test mode.acss_debitbacs_debitalipaygiropayidealcardradar_optionsmetadataSet 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.linkpromptpayoxxointerac_presentcustomerThe 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_accountboletoobjectString representing the object's type. Objects of the same type share the same value.konbinibilling_detailsblikwechat_paysofortp24createdTime at which the object was created. Measured in seconds since the Unix epoch.afterpay_clearpaytypeThe 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.grabpaybancontactau_becs_debitcustomer_balancecard_presentsepa_debitklarnapaynowidUnique identifier for the object.eps
Link to this section Functions
@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.
@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
@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
@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
:customerstring:ending_beforestring:expandarray of: string:limitinteger:starting_afterstring:type(Required) string
@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
:expandarray of: string
@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}