# `MishkaPay.Ash.Tenant`
[🔗](https://github.com/mishka-group/mishka_pay/blob/v0.0.1/lib/mishka_pay/ash/__helpers/tenant.ex#L6)

How the Ash layer finds the tenant a provider call is for (`MishkaPay.Credentials`), so it
works the same in a single-site project and in a multi-tenant one like Mishka CMS.

A Mishka Pay resource may carry Ash multitenancy on the host's own attribute:

    multitenancy do
      strategy :attribute
      attribute :site_id
    end

Its actions then run with the site as Ash's tenant (`tenant: site.id`), and that tenant is the
one the provider's keys are read for; the listeners sync each webhook's row inside the
webhook's own tenant (`/pay/webhooks/stripe/<site id>`). Without multitenancy the `:tenant`
argument says it. The row keeps it in its `:tenant` attribute either way, so later actions
(refund, cancel, edit) use the same keys. The webhook inbox stays global: a webhook arrives
before any tenant is chosen.

# `into`

```elixir
@spec into(map(), String.t() | nil) :: map()
```

`attrs` (a call's map) with `tenant` when they name none, so an action run in a site's Ash tenant
calls the provider with that site's keys.

# `of`

```elixir
@spec of(Ash.Changeset.t() | Ash.ActionInput.t()) :: String.t() | nil
```

The tenant of an action: a create's `:tenant` argument, else Ash's tenant; a generic action's
(`:start_checkout`) is Ash's tenant.

# `opts`

```elixir
@spec opts(module(), term()) :: keyword()
```

The Ash options a listener syncs `resource` with, for an event of `tenant`.

---

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