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
Functions
A sample %MishkaPay.Feature{} populated from defaults + type-based fallbacks.
Types
@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.
| Field | Type | Required | Default | Description | Derives |
|---|---|---|---|---|---|
:provider | String.t() | nil | no | sanitize(trim) validate(string, not_empty) | ||
:tenant | term() | nil | no | |||
:id | String.t() | nil | no | validate(string) | ||
:name | String.t() | nil | no | sanitize(trim) validate(string, not_empty, max_len=80) | ||
:lookup_key | String.t() | nil | no | sanitize(trim) validate(string, not_empty, max_len=80) | ||
:active | boolean() | nil | no | validate(boolean) | ||
:metadata | map() | nil | no | %{} | validate(map)<br>validator {MishkaPay.Checkout, :metadata} | |
:entitlement | MishkaPay.Feature.Entitlement.t() | nil | no | A 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. |