# `Accrue.Billing.PaymentMethod`
[🔗](https://github.com/szTheory/accrue/blob/accrue-v1.0.0/lib/accrue/billing/payment_method.ex#L1)

Ecto schema for the `accrue_payment_methods` table.

Stores processor-side payment method references (e.g. Stripe `pm_xxx`).
Card details are stored as Stripe references (brand, last4, expiry),
never as raw PAN or PII (CLAUDE.md security constraint).

Phase 3 adds:

  * `exp_month` / `exp_year` — top-level expiry used by the expiring-card
    notice scheduler (alias for the `card_exp_*` columns already in place)
  * `last_stripe_event_ts` / `last_stripe_event_id` — webhook watermark
  * virtual `existing?` — set by the `attach_payment_method/2` dedup path
    (Plan 06) when fingerprint matches an existing row on the customer

# `t`

```elixir
@type t() :: %Accrue.Billing.PaymentMethod{
  __meta__: term(),
  card_brand: term(),
  card_exp_month: term(),
  card_exp_year: term(),
  card_last4: term(),
  customer: term(),
  customer_id: term(),
  data: term(),
  existing?: term(),
  exp_month: term(),
  exp_year: term(),
  fingerprint: term(),
  id: term(),
  inserted_at: term(),
  is_default: term(),
  last_stripe_event_id: term(),
  last_stripe_event_ts: term(),
  lock_version: term(),
  metadata: term(),
  processor: term(),
  processor_id: term(),
  type: term(),
  updated_at: term()
}
```

# `changeset`

```elixir
@spec changeset(
  %Accrue.Billing.PaymentMethod{
    __meta__: term(),
    card_brand: term(),
    card_exp_month: term(),
    card_exp_year: term(),
    card_last4: term(),
    customer: term(),
    customer_id: term(),
    data: term(),
    existing?: term(),
    exp_month: term(),
    exp_year: term(),
    fingerprint: term(),
    id: term(),
    inserted_at: term(),
    is_default: term(),
    last_stripe_event_id: term(),
    last_stripe_event_ts: term(),
    lock_version: term(),
    metadata: term(),
    processor: term(),
    processor_id: term(),
    type: term(),
    updated_at: term()
  }
  | Ecto.Changeset.t(),
  map()
) :: Ecto.Changeset.t()
```

Builds a changeset for creating or updating a PaymentMethod.

---

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