# `MishkaPay.Check`
[🔗](https://github.com/mishka-group/mishka_pay/blob/v0.0.1/lib/mishka_pay/check.ex#L5)

Checks one site's setup before it takes money, the way a deploy or CI step would: each check is
`{name, :ok | {:error, reason}}`, in order, and `run/1` never raises. `mix mishka_pay.check`
prints them.

    MishkaPay.Check.run(provider: "stripe", tenant: site.id,
      webhook_url: "https://shop.test/pay/webhooks/stripe/#{site.id}", domain: MyApp.Pay)

What it checks:

  * `:provider`: the provider is installed and offered (`MishkaPay.Provider.fetch/1`);
  * `:keys`: the site's keys plugin answers keys for it (`MishkaPay.Credentials`);
  * `:keys_accepted`: the provider takes the keys, with one read call
    (`MishkaPay.Provider` `check_keys/1`, when the provider has it);
  * `:webhook_secret`: the keys carry the secret webhooks are checked with;
  * `:webhook_endpoint`: with `webhook_url:`, the provider sends every event Mishka Pay acts on
    to it (Stripe: `MishkaPay.Providers.Stripe.WebhookEndpoint`);
  * `:listeners`: with `domain:` (an Ash domain), each of its Mishka Pay listeners is started;
  * `:inbox`: with `domain:`, it has an `:inbox` resource, and Oban runs its queue.

# `result`

```elixir
@type result() :: {atom(), :ok | {:error, String.t()}}
```

# `ok?`

```elixir
@spec ok?([result()]) :: boolean()
```

Whether every check of `results` passed.

# `run`

```elixir
@spec run(keyword()) :: [result()]
```

Runs every check that applies to `opts`, and answers them in order.

---

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