# `MishkaPay.Ash.Resource.Info`
[🔗](https://github.com/mishka-group/mishka_pay/blob/v0.0.1/lib/mishka_pay/ash/__resource/info.ex#L6)

Reads the `mishka_pay` setup of a resource (`MishkaPay.Ash.Resource`): each option as
`mishka_pay_<option>/1`, such as `mishka_pay_kind/1` and `mishka_pay_listen?/1`, the actions it
took from its kind, and the listener made for it.

# `actions`

```elixir
@spec actions(Spark.Dsl.t() | Ash.Resource.t()) :: [atom()]
```

The actions the resource took from its kind: its `actions` option, else all of them.

# `listener`

```elixir
@spec listener(Spark.Dsl.t() | Ash.Resource.t()) :: module() | nil
```

The webhook listener module made for the resource (`listen? true`), or `nil`.

# `mishka_pay_actions`

```elixir
@spec mishka_pay_actions(dsl_or_extended :: module() | map()) ::
  {:ok, [atom()]} | :error
```

Only these actions of the kind, besides the primary `:read`. Every action of the kind
when left out. An `:inbox` needs all of its own.

# `mishka_pay_actions!`

```elixir
@spec mishka_pay_actions!(dsl_or_extended :: module() | map()) ::
  [atom()] | no_return()
```

Only these actions of the kind, besides the primary `:read`. Every action of the kind
when left out. An `:inbox` needs all of its own.

# `mishka_pay_announce?`

```elixir
@spec mishka_pay_announce?(dsl_or_extended :: module() | map()) :: boolean()
```

Fires `mishka_pay:<kind>:changed` after each write the provider answered. The inbox
announces nothing either way.

# `mishka_pay_belongs_to_user`

```elixir
@spec mishka_pay_belongs_to_user(dsl_or_extended :: module() | map()) ::
  {:ok, atom() | {atom(), keyword()}} | :error
```

A `:user` belongs_to relationship to the host's user resource, on `:user_id`, or on
another attribute with `{MyApp.Accounts.User, attribute: :owner_id}`. A payment or a
subscription gets its user from the checkout's owner, which `:start_checkout` takes from
the actor and every sync writes again (`MishkaPay.Ash.Owner`); a customer's `:register`
takes it as an input. It may be nil, for a sale with no owner.

# `mishka_pay_belongs_to_user!`

```elixir
@spec mishka_pay_belongs_to_user!(dsl_or_extended :: module() | map()) ::
  (atom() | {atom(), keyword()}) | no_return()
```

A `:user` belongs_to relationship to the host's user resource, on `:user_id`, or on
another attribute with `{MyApp.Accounts.User, attribute: :owner_id}`. A payment or a
subscription gets its user from the checkout's owner, which `:start_checkout` takes from
the actor and every sync writes again (`MishkaPay.Ash.Owner`); a customer's `:register`
takes it as an input. It may be nil, for a sale with no owner.

# `mishka_pay_code_interface?`

```elixir
@spec mishka_pay_code_interface?(dsl_or_extended :: module() | map()) :: boolean()
```

Defines a code interface function for each action it adds, such as
`MyApp.Pay.Subscription.cancel!(row, %{at: :now})`. The inbox's `:receive` is
`receive_event`.

# `mishka_pay_keep_events_for`

```elixir
@spec mishka_pay_keep_events_for(dsl_or_extended :: module() | map()) ::
  {:ok, pos_integer() | :forever} | :error
```

For an `:inbox`: how many days a processed event is kept before its daily `:forget`
trigger deletes it, or `:forever`. Failed and pending events are always kept.

# `mishka_pay_keep_events_for!`

```elixir
@spec mishka_pay_keep_events_for!(dsl_or_extended :: module() | map()) ::
  (pos_integer() | :forever) | no_return()
```

For an `:inbox`: how many days a processed event is kept before its daily `:forget`
trigger deletes it, or `:forever`. Failed and pending events are always kept.

# `mishka_pay_kind`

```elixir
@spec mishka_pay_kind(dsl_or_extended :: module() | map()) ::
  {:ok,
   :invoice
   | :payment_link
   | :promotion_code
   | :coupon
   | :price
   | :product
   | :dispute
   | :customer
   | :subscription
   | :payment
   | :inbox}
  | :error
```

What the resource keeps: `:inbox` (each checked webhook event), `:payment`,
`:subscription`, `:customer` or `:dispute`; or what a site manages from its admin:
`:product`, `:price`, `:coupon`, `:promotion_code`, `:payment_link` or `:invoice`
(`MishkaPay.Ash.Object.Spec`).

# `mishka_pay_kind!`

```elixir
@spec mishka_pay_kind!(dsl_or_extended :: module() | map()) ::
  (:invoice
   | :payment_link
   | :promotion_code
   | :coupon
   | :price
   | :product
   | :dispute
   | :customer
   | :subscription
   | :payment
   | :inbox)
  | no_return()
```

What the resource keeps: `:inbox` (each checked webhook event), `:payment`,
`:subscription`, `:customer` or `:dispute`; or what a site manages from its admin:
`:product`, `:price`, `:coupon`, `:promotion_code`, `:payment_link` or `:invoice`
(`MishkaPay.Ash.Object.Spec`).

# `mishka_pay_listen?`

```elixir
@spec mishka_pay_listen?(dsl_or_extended :: module() | map()) :: boolean()
```

Makes `<Resource>.MishkaPayListener`, the webhook listener that keeps the resource
current. `MishkaPay.Ash.listeners/1` lists them for the application's children.

# `mishka_pay_options`

```elixir
@spec mishka_pay_options(dsl_or_extended :: module() | map()) :: %{
  required(atom()) =&gt; any()
}
```

mishka_pay DSL options

Returns a map containing the and any configured or default values.

# `mishka_pay_resync_after`

```elixir
@spec mishka_pay_resync_after(dsl_or_extended :: module() | map()) ::
  {:ok, pos_integer()} | :error
```

Hours after which a row still open at its provider is read again by an hourly AshOban
trigger running `:resync`, in case a webhook never came: a pending or authorized
payment, a subscription that has not ended, an open dispute, a draft or open bill.
Runs on the inbox's queue, `mishka_pay_inbox`. Off unless given.

# `mishka_pay_resync_after!`

```elixir
@spec mishka_pay_resync_after!(dsl_or_extended :: module() | map()) ::
  pos_integer() | no_return()
```

Hours after which a row still open at its provider is read again by an hourly AshOban
trigger running `:resync`, in case a webhook never came: a pending or authorized
payment, a subscription that has not ended, an open dispute, a draft or open bill.
Runs on the inbox's queue, `mishka_pay_inbox`. Off unless given.

# `mishka_pay_tenant_from`

```elixir
@spec mishka_pay_tenant_from(dsl_or_extended :: module() | map()) ::
  {:ok, atom()} | :error
```

The host's own attribute that holds the tenant, such as `:site_id` (an attribute, or the
source attribute of a `belongs_to :site`), for a host that keeps sites apart without Ash
multitenancy. Each create action writes its tenant there too; the row's `:tenant` still
picks the provider keys. With Ash multitenancy on that attribute, Ash fills it and this is
not needed. Not for an `:inbox`, which stays global.

# `mishka_pay_tenant_from!`

```elixir
@spec mishka_pay_tenant_from!(dsl_or_extended :: module() | map()) ::
  atom() | no_return()
```

The host's own attribute that holds the tenant, such as `:site_id` (an attribute, or the
source attribute of a `belongs_to :site`), for a host that keeps sites apart without Ash
multitenancy. Each create action writes its tenant there too; the row's `:tenant` still
picks the provider keys. With Ash multitenancy on that attribute, Ash fills it and this is
not needed. Not for an `:inbox`, which stays global.

# `user_attribute`

```elixir
@spec user_attribute(Spark.Dsl.t() | Ash.Resource.t()) :: atom() | nil
```

The attribute `belongs_to_user` keeps the user in (`:user_id` unless named), or `nil`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
