MishkaPay.Customer.PaymentMethod (Mishka Pay v0.0.1)

Copy Markdown View Source

A payment method a customer saved at the provider (pm_... at Stripe), such as a card, so a later invoice or subscription charges it without the buyer typing it again. A guarded_struct the provider fills in.

A checkout in mode: :setup saves one (MishkaPay.Checkout). Read with MishkaPay.fetch_payment_method/3 and MishkaPay.list_payment_methods/3, made the customer's default with MishkaPay.set_default_payment_method/4, and taken off the customer with MishkaPay.detach_payment_method/3.

  • :provider: which provider keeps it.
  • :id: the provider's id of the payment method.
  • :customer_id: the customer it is saved on; nil once it is taken off.
  • :type: the provider's kind of payment method, such as "card" or "sepa_debit".
  • :card_brand, :card_last4, :card_exp_month, :card_exp_year: for a card, its brand ("visa"), its last four digits and when it expires; nil for other kinds.
  • :created_at: when it was saved.

Summary

Types

t()

The struct that builder/1 returns.

Functions

A sample %MishkaPay.Customer.PaymentMethod{} populated from defaults + type-based fallbacks.

Types

t()

@type t() :: %MishkaPay.Customer.PaymentMethod{
  card_brand: String.t() | nil,
  card_exp_month: pos_integer() | nil,
  card_exp_year: pos_integer() | nil,
  card_last4: String.t() | nil,
  created_at: DateTime.t() | nil,
  customer_id: String.t() | nil,
  id: String.t() | nil,
  provider: String.t() | nil,
  type: String.t() | nil
}

The struct that builder/1 returns.

FieldTypeRequiredDefaultDescriptionDerives
:providerString.t() | nilnovalidate(string, not_empty)
:idString.t() | nilnovalidate(string, not_empty)
:customer_idString.t() | nilnovalidate(string)
:typeString.t() | nilnovalidate(string)
:card_brandString.t() | nilnovalidate(string)
:card_last4String.t() | nilnovalidate(string)
:card_exp_monthpos_integer() | nilnovalidate(integer)
:card_exp_yearpos_integer() | nilnovalidate(integer)
:created_atDateTime.t() | nilnovalidate(struct)

Functions

builder(attrs_or_input, error \\ false)

enforce_keys()

enforce_keys(field)

example()

A sample %MishkaPay.Customer.PaymentMethod{} populated from defaults + type-based fallbacks.

keys()

keys(field)