A payment method saved for later on the site's own page, with the provider's card form (Stripe
Elements) and no charge: made on the server with MishkaPay.create_setup_intent/1, its
:client_secret handed to that buyer's browser, where the provider's script shows the form and
confirms it. Read with MishkaPay.fetch_setup_intent/3, confirmed on the server with
MishkaPay.confirm_setup_intent/4, and ended with MishkaPay.cancel_setup_intent/3. Once it
succeeded, its :payment_method_id is on the customer: MishkaPay.list_payment_methods/3
lists it. A guarded_struct.
What the caller gives:
:provider,:tenant: which provider, with whose keys.:customer_id: the provider customer who keeps the payment method. Without one, the payment method is saved but on no customer, and can be used once.:payment_method_id: a payment method to save, to confirm it without the form.:usage::off_session(the provider's default) for later charges without the buyer,:on_sessionfor later payments the buyer makes.:automatic_payment_methods:true(the default) offers the payment methods turned on in the provider's dashboard;falseoffers cards only.:description,:metadata: kept with it.:reference: the caller's own id for it; it makes the idempotency key, so the same reference never makes two, and it comes back on it.
What the provider fills in: :id (seti_... at Stripe), :client_secret (send it only to
that buyer's page), :status (:requires_payment_method, :requires_confirmation,
:requires_action, :processing, :succeeded or :canceled), :failure_code,
:failure_message and :created_at.
Summary
Functions
A sample %MishkaPay.SetupIntent{} populated from defaults + type-based fallbacks.
The statuses a setup intent can have.
Types
@type t() :: %MishkaPay.SetupIntent{ automatic_payment_methods: boolean() | nil, client_secret: String.t() | nil, created_at: DateTime.t() | nil, customer_id: String.t() | nil, description: String.t() | nil, failure_code: String.t() | nil, failure_message: String.t() | nil, id: String.t() | nil, metadata: map() | nil, payment_method_id: String.t() | nil, provider: String.t(), reference: String.t() | nil, status: atom() | nil, tenant: term() | nil, usage: (:on_session | :off_session) | nil }
The struct that builder/1 returns.
| Field | Type | Required | Default | Description | Derives |
|---|---|---|---|---|---|
:provider | String.t() | yes | sanitize(trim) validate(not_nil_value, string, not_empty) | ||
:tenant | term() | nil | no | |||
:id | String.t() | nil | no | sanitize(trim) validate(string, not_empty) | ||
:customer_id | String.t() | nil | no | sanitize(trim) validate(string, not_empty) | ||
:payment_method_id | String.t() | nil | no | sanitize(trim) validate(string, not_empty) | ||
:usage | :on_session | :off_session | nil | no | validate(enum=Atom[on_session::off_session])<br>validator {MishkaPay.PaymentIntent, :usage} | ||
:automatic_payment_methods | boolean() | nil | no | validate(boolean) | ||
:description | String.t() | nil | no | sanitize(trim) validate(string, max_len=1000) | ||
:reference | String.t() | nil | no | sanitize(trim) validate(string, not_empty, max_len=200) | ||
:metadata | map() | nil | no | %{} | validate(map)<br>validator {MishkaPay.Checkout, :metadata} | |
:client_secret | String.t() | nil | no | validate(string) | ||
:status | atom() | nil | no | validate(enum=Atom[requires_payment_method::requires_confirmation::requires_action::processing::succeeded::canceled]) | ||
:failure_code | String.t() | nil | no | validate(string) | ||
:failure_message | String.t() | nil | no | validate(string) | ||
:created_at | DateTime.t() | nil | no | validate(struct) |
Functions
A sample %MishkaPay.SetupIntent{} populated from defaults + type-based fallbacks.
@spec statuses() :: [atom()]
The statuses a setup intent can have.