# `Stripe.CustomerBalanceTransaction`
[🔗](https://github.com/code-corps/stripity_stripe/blob/v3.3.3/lib/generated/customer_balance_transaction.ex#L1)

Each customer has a [Balance](https://stripe.com/docs/api/customers/object#customer_object-balance) value,
which denotes a debit or credit that's automatically applied to their next invoice upon finalization.
You may modify the value directly by using the [update customer API](https://stripe.com/docs/api/customers/update),
or by creating a Customer Balance Transaction, which increments or decrements the customer's `balance` by the specified `amount`.

Related guide: [Customer balance](https://stripe.com/docs/billing/customer/balance)

# `created`

```elixir
@type created() :: %{
  optional(:gt) =&gt; integer(),
  optional(:gte) =&gt; integer(),
  optional(:lt) =&gt; integer(),
  optional(:lte) =&gt; integer()
}
```

# `t`

```elixir
@type t() :: %Stripe.CustomerBalanceTransaction{
  amount: integer(),
  checkout_session: (binary() | Stripe.Checkout.Session.t()) | nil,
  created: integer(),
  credit_note: (binary() | Stripe.CreditNote.t()) | nil,
  currency: binary(),
  customer: binary() | Stripe.Customer.t(),
  description: binary() | nil,
  ending_balance: integer(),
  id: binary(),
  invoice: (binary() | Stripe.Invoice.t()) | nil,
  livemode: boolean(),
  metadata: term() | nil,
  object: binary(),
  type: binary()
}
```

The `customer_balance_transaction` type.

  * `amount` The amount of the transaction. A negative value is a credit for the customer's balance, and a positive value is a debit to the customer's `balance`.
  * `checkout_session` The ID of the checkout session (if any) that created the transaction.
  * `created` Time at which the object was created. Measured in seconds since the Unix epoch.
  * `credit_note` The ID of the credit note (if any) related to the transaction.
  * `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
  * `customer` The ID of the customer the transaction belongs to.
  * `description` An arbitrary string attached to the object. Often useful for displaying to users.
  * `ending_balance` The customer's `balance` after the transaction was applied. A negative value decreases the amount due on the customer's next invoice. A positive value increases the amount due on the customer's next invoice.
  * `id` Unique identifier for the object.
  * `invoice` The ID of the invoice (if any) related to the transaction.
  * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
  * `metadata` Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
  * `object` String representing the object's type. Objects of the same type share the same value.
  * `type` Transaction type: `adjustment`, `applied_to_invoice`, `credit_note`, `initial`, `invoice_overpaid`, `invoice_too_large`, `invoice_too_small`, `unspent_receiver_credit`, `unapplied_from_invoice`, `checkout_session_subscription_payment`, or `checkout_session_subscription_payment_canceled`. See the [Customer Balance page](https://stripe.com/docs/billing/customer/balance#types) to learn more about transaction types.

# `create`

```elixir
@spec create(
  customer :: binary(),
  params :: %{
    optional(:amount) =&gt; integer(),
    optional(:currency) =&gt; binary(),
    optional(:description) =&gt; binary(),
    optional(:expand) =&gt; [binary()],
    optional(:metadata) =&gt; %{optional(binary()) =&gt; binary()} | binary()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
```

<p>Creates an immutable transaction that updates the customer’s credit <a href="/docs/billing/customer/balance">balance</a>.</p>

#### Details

 * Method: `post`
 * Path: `/v1/customers/{customer}/balance_transactions`

# `list`

```elixir
@spec list(
  customer :: binary(),
  params :: %{
    optional(:created) =&gt; created() | integer(),
    optional(:ending_before) =&gt; binary(),
    optional(:expand) =&gt; [binary()],
    optional(:limit) =&gt; integer(),
    optional(:starting_after) =&gt; binary()
  },
  opts :: Keyword.t()
) ::
  {:ok, Stripe.List.t(t())} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
```

<p>Returns a list of transactions that updated the customer’s <a href="/docs/billing/customer/balance">balances</a>.</p>

#### Details

 * Method: `get`
 * Path: `/v1/customers/{customer}/balance_transactions`

# `retrieve`

```elixir
@spec retrieve(
  customer :: binary(),
  transaction :: binary(),
  params :: %{optional(:expand) =&gt; [binary()]},
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
```

<p>Retrieves a specific customer balance transaction that updated the customer’s <a href="/docs/billing/customer/balance">balances</a>.</p>

#### Details

 * Method: `get`
 * Path: `/v1/customers/{customer}/balance_transactions/{transaction}`

# `update`

```elixir
@spec update(
  customer :: binary(),
  transaction :: binary(),
  params :: %{
    optional(:description) =&gt; binary(),
    optional(:expand) =&gt; [binary()],
    optional(:metadata) =&gt; %{optional(binary()) =&gt; binary()} | binary()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
```

<p>Most credit balance transaction fields are immutable, but you may update its <code>description</code> and <code>metadata</code>.</p>

#### Details

 * Method: `post`
 * Path: `/v1/customers/{customer}/balance_transactions/{transaction}`

---

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