# `Codat.BillPay.Payments`
[🔗](https://github.com/iamkanishka/codat.git/blob/v1.0.0/lib/codat/bill_pay/bill_pay.ex#L50)

Create and track bill payments through the Bill Pay API.

Payments are written to the customer's accounting platform, marking bills
as (partially) paid and creating the corresponding payment record.

## Example

    # Create a bill payment
    {:ok, push_op} = Codat.BillPay.Payments.create(
      client, company_id, connection_id,
      %{
        date: "2024-01-20",
        supplierRef: %{id: "supplier-id"},
        lines: [
          %{
            amount: 5000.00,
            links: [
              %{type: "Bill", id: "bill-id", amount: -5000.00}
            ]
          }
        ],
        accountRef: %{id: "bank-account-id"}
      }
    )

    # Wait for confirmation
    {:ok, done} = Codat.Platform.PushOperations.poll_until_done(
      client, company_id, push_op["pushOperationKey"]
    )

# `create`

```elixir
@spec create(
  Codat.Client.t() | String.t(),
  String.t(),
  String.t() | map(),
  map() | keyword()
) ::
  {:ok, map()} | {:error, Codat.Error.t()}
```

Creates a new billPayments (async). Returns a push operation.

# `delete`

```elixir
@spec delete(Codat.Client.t() | String.t(), String.t(), String.t() | keyword()) ::
  {:ok, nil} | {:error, Codat.Error.t()}
```

Deletes a billPayments by ID (async).

# `fetch_all`

```elixir
@spec fetch_all(Codat.Client.t() | String.t(), String.t() | keyword(), keyword()) ::
  {:ok, [map()]} | {:error, Codat.Error.t()}
```

Fetches all billPayments across all pages concurrently.

# `get`

```elixir
@spec get(Codat.Client.t() | String.t(), String.t(), String.t() | keyword()) ::
  {:ok, map()} | {:error, Codat.Error.t()}
```

Fetches a single billPayments by ID.

# `get_create_model`

```elixir
@spec get_create_model(Codat.Client.t() | String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, Codat.Error.t()}
```

Returns the push model for creating billPayments.

# `list`

```elixir
@spec list(Codat.Client.t() | String.t(), String.t() | keyword(), keyword()) ::
  {:ok, Codat.Pagination.t()} | {:error, Codat.Error.t()}
```

Returns a paginated list of billPayments.

# `stream`

```elixir
@spec stream(Codat.Client.t() | String.t(), String.t() | keyword(), keyword()) ::
  Enumerable.t()
```

Returns a lazy `Stream` of all results.

---

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