MishkaPay.PortalSession.Configuration (Mishka Pay v0.0.1)

Copy Markdown View Source

What buyers may do in the provider's customer portal (MishkaPay.PortalSession), kept at the provider as one setup a portal session names by :configuration: a site can keep one for monthly buyers and another for teams. Made with MishkaPay.create_portal_configuration/1, changed with MishkaPay.update_portal_configuration/1, read with MishkaPay.fetch_portal_configuration/3 and MishkaPay.list_portal_configurations/3. A guarded_struct.

What the caller gives, every field optional (a change sends only what it names):

  • :provider, :tenant: which provider, with whose keys.
  • :name: the host's own name for it; :active: false turns it off (a provider never deletes one).
  • The portal page's header: :headline, :privacy_policy_url, :terms_of_service_url; and :default_return_url, where buyers go back when a session names no return_url.
  • :invoice_history: true shows their past bills; :payment_method_update: true lets them change their card.
  • :customer_update: which of their details they may change, from :email, :address, :shipping, :phone, :tax_id, :name; [] none.
  • :subscription_cancel: :immediately, :at_period_end, or :off.
  • :subscription_update: what they may change on a plan, from :price, :quantity, :promotion_code; [] nothing. With :price, :plans (MishkaPay.PortalSession.Configuration.Plans) lists the products and prices they may switch to, and :proration says how the change bills: :create_prorations, :always_invoice or :none.
  • :metadata: extra pairs, string keys to string values.

What the provider fills in: :id (bpc_... at Stripe), :default (true for the one a session without :configuration uses), :created_at.

Plans

Each of :plans is a MishkaPay.PortalSession.Configuration.Plans, a sub_field of this struct: a product a buyer may switch their subscription to in the customer portal, with the prices of it on offer.

  • :product_id: the catalog product (MishkaPay.Product).
  • :price_ids: its recurring prices the buyer may pick, one or more.

Summary

Types

t()

The struct that builder/1 returns.

Functions

A sample %MishkaPay.PortalSession.Configuration{} populated from defaults + type-based fallbacks.

Types

t()

@type t() :: %MishkaPay.PortalSession.Configuration{
  active: boolean() | nil,
  created_at: DateTime.t() | nil,
  customer_update: list() | nil,
  default: boolean() | nil,
  default_return_url: String.t() | nil,
  headline: String.t() | nil,
  id: String.t() | nil,
  invoice_history: boolean() | nil,
  metadata: map() | nil,
  name: String.t() | nil,
  payment_method_update: boolean() | nil,
  plans: [MishkaPay.PortalSession.Configuration.Plans.t()] | nil,
  privacy_policy_url: String.t() | nil,
  proration: (:create_prorations | :always_invoice | :none) | nil,
  provider: String.t(),
  subscription_cancel: (:off | :immediately | :at_period_end) | nil,
  subscription_update: list() | nil,
  tenant: term() | nil,
  terms_of_service_url: String.t() | nil
}

The struct that builder/1 returns.

FieldTypeRequiredDefaultDescriptionDerives
:providerString.t()yessanitize(trim) validate(not_nil_value, string, not_empty)
:tenantterm() | nilno
:idString.t() | nilnosanitize(trim) validate(string, not_empty)
:nameString.t() | nilnosanitize(trim) validate(string, not_empty, max_len=256)
:activeboolean() | nilnovalidate(boolean)
:defaultboolean() | nilnovalidate(boolean)
:headlineString.t() | nilnosanitize(trim) validate(string, not_empty, max_len=60)
:privacy_policy_urlString.t() | nilnosanitize(trim) validate(string, not_empty)
:terms_of_service_urlString.t() | nilnosanitize(trim) validate(string, not_empty)
:default_return_urlString.t() | nilnosanitize(trim) validate(string, not_empty)
:invoice_historyboolean() | nilnovalidate(boolean)
:payment_method_updateboolean() | nilnovalidate(boolean)
:customer_updatelist() | nilnovalidator {MishkaPay.PortalSession.Configuration, :customer_update}
:subscription_cancel:off | :immediately | :at_period_end | nilnovalidate(enum=Atom[off::immediately::at_period_end])<br>validator {MishkaPay.PortalSession.Configuration, :subscription_cancel}
:subscription_updatelist() | nilnovalidator {MishkaPay.PortalSession.Configuration, :subscription_update}
:plans[MishkaPay.PortalSession.Configuration.Plans.t()] | nilnovalidate(list)
:proration:create_prorations | :always_invoice | :none | nilnovalidate(enum=Atom[create_prorations::always_invoice::none])<br>validator {MishkaPay.PortalSession.Configuration, :proration}
:metadatamap() | nilno%{}validate(map)<br>validator {MishkaPay.Checkout, :metadata}
:created_atDateTime.t() | nilnovalidate(struct)

Functions

builder(attrs_or_input, error \\ false)

enforce_keys()

enforce_keys(field)

example()

A sample %MishkaPay.PortalSession.Configuration{} populated from defaults + type-based fallbacks.

keys()

keys(field)