MishkaPay.PortalSession (Mishka Pay v0.0.1)

Copy Markdown View Source

A link to the provider's own billing page for one customer (Stripe's customer portal), made with MishkaPay.portal_session/1. Send the buyer to :url; there they update their card, see their invoices, and change or cancel their plan as the provider's settings allow, then come back to :return_url. What they change reaches the host through its webhooks. A guarded_struct.

What the caller gives: :provider, :tenant, :customer_id, :return_url (https, or http on localhost), and optionally :configuration, the provider's id of a portal setup other than its default.

:flow opens the page on one task instead of its home, and sends the buyer back to :return_url when it is done: :subscription_cancel or :subscription_update (with :subscription_id), or :payment_method_update (the card on file).

What the provider fills in: :id and :url. The link is short-lived: make one per click.

Summary

Types

t()

The struct that builder/1 returns.

Functions

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

Types

t()

@type t() :: %MishkaPay.PortalSession{
  configuration: String.t() | nil,
  customer_id: String.t(),
  flow:
    (:subscription_cancel | :subscription_update | :payment_method_update) | nil,
  id: String.t() | nil,
  provider: String.t(),
  return_url: String.t(),
  subscription_id: String.t() | nil,
  tenant: term() | nil,
  url: String.t() | nil
}

The struct that builder/1 returns.

FieldTypeRequiredDefaultDescriptionDerives
:providerString.t()yessanitize(trim) validate(not_nil_value, string, not_empty)
:tenantterm() | nilno
:customer_idString.t()yessanitize(trim) validate(not_nil_value, string, not_empty)
:return_urlString.t()yessanitize(trim) validate(not_nil_value, string, not_empty)<br>validator {MishkaPay.Checkout, :return_url}
:configurationString.t() | nilnosanitize(trim) validate(string, not_empty)
:flow:subscription_cancel | :subscription_update | :payment_method_update | nilnovalidate(enum=Atom[subscription_cancel::subscription_update::payment_method_update])<br>validator {MishkaPay.PortalSession, :flow}
:subscription_idString.t() | nilnosanitize(trim) validate(string, not_empty)
:idString.t() | nilnovalidate(string)
:urlString.t() | nilnovalidate(string)

Functions

builder(attrs_or_input, error \\ false)

enforce_keys()

enforce_keys(field)

example()

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

keys()

keys(field)