Something sold, as the provider keeps it in its catalog (prod_... at Stripe), with its prices
(MishkaPay.Price with :product_id). A guarded_struct.
Made with MishkaPay.create_product/1, changed with MishkaPay.update_product/1, taken off sale
with MishkaPay.archive_product/3, read with MishkaPay.fetch_product/3 and
MishkaPay.list_products/3. A checkout sells a catalog price by its id (items: [%{id: "price_..."}]).
What the caller gives:
:provider,:tenant: which provider, with whose keys.:id: optional, the product's own id ("shop-ebook"); the provider makes one when it is left out.:name,:description: what the buyer sees.:tax_code: the provider's tax category, such as Stripe's"txcd_10302000".:active: on sale (trueby default);falsekeeps it for past sales only.:metadata: extra pairs, string keys to string values.
What the provider fills in: :default_price_id, :created_at.
Summary
Functions
A sample %MishkaPay.Product{} populated from defaults + type-based fallbacks.
Types
@type t() :: %MishkaPay.Product{ active: boolean() | nil, created_at: DateTime.t() | nil, default_price_id: String.t() | nil, description: String.t() | nil, id: String.t() | nil, metadata: map() | nil, name: String.t() | nil, provider: String.t() | nil, tax_code: 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 | sanitize(trim) validate(string, not_empty, max_len=200) | ||
:name | String.t() | nil | no | sanitize(trim) validate(string, not_empty, max_len=250) | ||
:description | String.t() | nil | no | sanitize(trim) validate(string, not_empty, max_len=1000) | ||
:tax_code | String.t() | nil | no | sanitize(trim) validate(string, not_empty, max_len=100) | ||
:active | boolean() | nil | no | validate(boolean) | ||
:metadata | map() | nil | no | %{} | validate(map)<br>validator {MishkaPay.Checkout, :metadata} | |
:default_price_id | String.t() | nil | no | validate(string) | ||
:created_at | DateTime.t() | nil | no | validate(struct) |