MishkaPay.ShippingRate (Mishka Pay v0.0.1)

Copy Markdown View Source

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 (for create_shipping_rate/1).
  • :name: what the buyer reads, such as "Standard post".
  • :amount: what shipping costs for the whole order, as Money; 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, :exclusive or :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

Types

t()

The struct that builder/1 returns.

Functions

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

Types

t()

@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.

FieldTypeRequiredDefaultDescriptionDerives
:providerString.t() | nilnosanitize(trim) validate(string, not_empty)
:tenantterm() | nilno
:idString.t() | nilnosanitize(trim) validate(string, not_empty)
:nameString.t() | nilnosanitize(trim) validate(string, not_empty, max_len=100)
:amountMoney.t() | nilnovalidator {MishkaPay.Money, :field}
:min_dayspos_integer() | nilnovalidate(integer, min_len=1)
:max_dayspos_integer() | nilnovalidate(integer, min_len=1)
:tax_codeString.t() | nilnosanitize(trim) validate(string, not_empty, max_len=100)
:tax_behavior:inclusive | :exclusive | nilnovalidate(enum=Atom[inclusive::exclusive])<br>validator {MishkaPay.Price, :tax_behavior}
:activeboolean() | nilnovalidate(boolean)
:metadatamap() | nilno%{}validate(map)<br>validator {MishkaPay.Checkout, :metadata}
:created_atDateTime.t() | nilnovalidate(struct)

Functions

builder(attrs_or_input, error \\ false)

enforce_keys()

enforce_keys(field)

example()

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

keys()

keys(field)