# `Accrue.Checkout.Session`
[🔗](https://github.com/szTheory/accrue/blob/accrue-v1.0.0/lib/accrue/checkout/session.ex#L1)

Stripe Checkout Session wrapper.

Wraps the processor-level `checkout_session_create/2` and
`checkout_session_fetch/2` callbacks, projects the raw Stripe
payload into a tightly-typed struct, and masks the embedded-mode
`:client_secret` field in `Inspect` output — anyone
holding a `client_secret` can mount the embedded checkout flow on
the customer's behalf until the session expires.

Two `ui_mode` values are supported:

  * `:hosted` (default) — Stripe-hosted Checkout page; the
    returned `%Session{}` has a `:url` to redirect the customer to.
  * `:embedded` — the host app mounts Stripe.js's embedded form;
    the returned `%Session{}` has a `:client_secret` to hand to
    the front end.

The `:mode` option mirrors the Stripe Checkout `mode` parameter:
`:subscription` (default), `:payment`, or `:setup`.

# `t`

```elixir
@type t() :: %Accrue.Checkout.Session{
  amount_tax: term(),
  amount_total: term(),
  automatic_tax: term(),
  client_secret: term(),
  currency: term(),
  customer: term(),
  data: term(),
  expires_at: term(),
  id: term(),
  metadata: term(),
  mode: term(),
  object: term(),
  payment_intent: term(),
  payment_status: term(),
  status: term(),
  subscription: term(),
  ui_mode: term(),
  url: term()
}
```

# `create`

```elixir
@spec create(map() | keyword()) :: {:ok, t()} | {:error, term()}
```

Creates a Checkout Session through the configured processor.

See module docs for accepted options. Returns `{:ok, %Session{}}`
on success.

# `create!`

```elixir
@spec create!(map() | keyword()) :: t()
```

Bang variant of `create/1`. Raises `Accrue.APIError` (or a generic
`RuntimeError`) on failure.

# `retrieve`

```elixir
@spec retrieve(String.t()) :: {:ok, t()} | {:error, term()}
```

Retrieves a Checkout Session by id.

---

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