A way to ship an order and what it costs (shr_... at Stripe): kept by the provider with
MishkaPay.create_shipping_rate/1 and offered by its id, or given inline on one checkout. The
buyer picks one on the checkout's page (MishkaPay.Checkout's :shipping_rates). A
guarded_struct.
What the caller gives:
:provider,:tenant: which provider, with whose keys (forcreate_shipping_rate/1).:name: what the buyer reads, such as "Standard post".:amount: what shipping costs for the whole order, asMoney; zero ships free.:min_days,:max_days: the delivery estimate, in business days.:tax_code: the provider's tax category of shipping (Stripe's"txcd_92010001"), and:tax_behavior,:exclusiveor:inclusive, for a provider that counts the tax.:metadata: extra pairs, string keys to string values.:id: on a checkout, a rate the provider already keeps; then nothing else is needed.
What the provider fills in: :id, :active, :created_at.
Summary
Functions
A sample %MishkaPay.ShippingRate{} populated from defaults + type-based fallbacks.
Types
@type t() :: %MishkaPay.ShippingRate{ active: boolean() | nil, amount: Money.t() | nil, created_at: DateTime.t() | nil, id: String.t() | nil, max_days: pos_integer() | nil, metadata: map() | nil, min_days: pos_integer() | nil, name: String.t() | nil, provider: String.t() | nil, tax_behavior: (:inclusive | :exclusive) | 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) | ||
:name | String.t() | nil | no | sanitize(trim) validate(string, not_empty, max_len=100) | ||
:amount | Money.t() | nil | no | validator {MishkaPay.Money, :field} | ||
:min_days | pos_integer() | nil | no | validate(integer, min_len=1) | ||
:max_days | pos_integer() | nil | no | validate(integer, min_len=1) | ||
:tax_code | String.t() | nil | no | sanitize(trim) validate(string, not_empty, max_len=100) | ||
:tax_behavior | :inclusive | :exclusive | nil | no | validate(enum=Atom[inclusive::exclusive])<br>validator {MishkaPay.Price, :tax_behavior} | ||
:active | boolean() | nil | no | validate(boolean) | ||
:metadata | map() | nil | no | %{} | validate(map)<br>validator {MishkaPay.Checkout, :metadata} | |
:created_at | DateTime.t() | nil | no | validate(struct) |