MishkaPay.Feature (Mishka Pay v0.0.1)

Copy Markdown View Source

Something a customer may be entitled to use, such as "seats" or "api-access" (feat_... at Stripe). A guarded_struct.

Made with MishkaPay.create_feature/1 and attached to a catalog product with MishkaPay.attach_feature/4. A customer who buys the product gets a MishkaPay.Feature.Entitlement to it, which MishkaPay.list_entitlements/4 reads.

What the caller gives:

  • :provider, :tenant: which provider, with whose keys.
  • :name: its name, for the seller only.
  • :lookup_key: the host's own key for it, which the code checks access by.
  • :metadata: extra pairs, string keys to string values.

What the provider fills in: :id and :active.

Summary

Types

t()

The struct that builder/1 returns.

Functions

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

Types

t()

@type t() :: %MishkaPay.Feature{
  active: boolean() | nil,
  entitlement: MishkaPay.Feature.Entitlement.t() | nil,
  id: String.t() | nil,
  lookup_key: String.t() | nil,
  metadata: map() | nil,
  name: String.t() | nil,
  provider: String.t() | nil,
  tenant: term() | nil
}

The struct that builder/1 returns.

FieldTypeRequiredDefaultDescriptionDerives
:providerString.t() | nilnosanitize(trim) validate(string, not_empty)
:tenantterm() | nilno
:idString.t() | nilnovalidate(string)
:nameString.t() | nilnosanitize(trim) validate(string, not_empty, max_len=80)
:lookup_keyString.t() | nilnosanitize(trim) validate(string, not_empty, max_len=80)
:activeboolean() | nilnovalidate(boolean)
:metadatamap() | nilno%{}validate(map)<br>validator {MishkaPay.Checkout, :metadata}
:entitlementMishkaPay.Feature.Entitlement.t() | nilnoA customer's access to a MishkaPay.Feature right now, given by a product they bought, read with MishkaPay.list_entitlements/4. A guarded_struct the provider fills in.

Functions

builder(attrs_or_input, error \\ false)

enforce_keys()

enforce_keys(field)

example()

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

keys()

keys(field)