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

Issue a credit note to adjust an invoice's amount after the invoice is finalized.

Related guide: [Credit notes](https://stripe.com/docs/billing/invoices/credit-notes)

# `created`

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

# `lines`

```elixir
@type lines() :: %{
  optional(:amount) =&gt; integer(),
  optional(:description) =&gt; binary(),
  optional(:invoice_line_item) =&gt; binary(),
  optional(:quantity) =&gt; integer(),
  optional(:tax_amounts) =&gt; [tax_amounts()] | binary(),
  optional(:tax_rates) =&gt; [binary()] | binary(),
  optional(:type) =&gt; :custom_line_item | :invoice_line_item,
  optional(:unit_amount) =&gt; integer(),
  optional(:unit_amount_decimal) =&gt; binary()
}
```

# `payment_record_refund`

```elixir
@type payment_record_refund() :: %{
  optional(:payment_record) =&gt; binary(),
  optional(:refund_group) =&gt; binary()
}
```

The PaymentRecord refund details to link to this credit note. Required when `type` is `payment_record_refund`.

# `refunds`

```elixir
@type refunds() :: %{
  optional(:amount_refunded) =&gt; integer(),
  optional(:payment_record_refund) =&gt; payment_record_refund(),
  optional(:refund) =&gt; binary(),
  optional(:type) =&gt; :payment_record_refund | :refund
}
```

# `shipping_cost`

```elixir
@type shipping_cost() :: %{optional(:shipping_rate) =&gt; binary()}
```

# `t`

```elixir
@type t() :: %Stripe.CreditNote{
  amount: integer(),
  amount_shipping: integer(),
  created: integer(),
  currency: binary(),
  customer: binary() | Stripe.Customer.t() | Stripe.DeletedCustomer.t(),
  customer_balance_transaction:
    (binary() | Stripe.CustomerBalanceTransaction.t()) | nil,
  discount_amount: integer(),
  discount_amounts: term(),
  effective_at: integer() | nil,
  id: binary(),
  invoice: binary() | Stripe.Invoice.t(),
  lines: term(),
  livemode: boolean(),
  memo: binary() | nil,
  metadata: term() | nil,
  number: binary(),
  object: binary(),
  out_of_band_amount: integer() | nil,
  pdf: binary(),
  post_payment_amount: integer(),
  pre_payment_amount: integer(),
  pretax_credit_amounts: term(),
  reason: binary() | nil,
  refunds: term(),
  shipping_cost: term() | nil,
  status: binary(),
  subtotal: integer(),
  subtotal_excluding_tax: integer() | nil,
  total: integer(),
  total_excluding_tax: integer() | nil,
  total_taxes: term() | nil,
  type: binary(),
  voided_at: integer() | nil
}
```

The `credit_note` type.

  * `amount` The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax.
  * `amount_shipping` This is the sum of all the shipping amounts.
  * `created` Time at which the object was created. Measured in seconds since the Unix epoch.
  * `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` ID of the customer.
  * `customer_balance_transaction` Customer balance transaction related to this credit note.
  * `discount_amount` The integer amount in cents (or local equivalent) representing the total amount of discount that was credited.
  * `discount_amounts` The aggregate amounts calculated per discount for all line items.
  * `effective_at` The date when this credit note is in effect. Same as `created` unless overwritten. When defined, this value replaces the system-generated 'Date of issue' printed on the credit note PDF.
  * `id` Unique identifier for the object.
  * `invoice` ID of the invoice.
  * `lines` Line items that make up the credit note
  * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
  * `memo` Customer-facing text that appears on the credit note PDF.
  * `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.
  * `number` A unique number that identifies this particular credit note and appears on the PDF of the credit note and its associated invoice.
  * `object` String representing the object's type. Objects of the same type share the same value.
  * `out_of_band_amount` Amount that was credited outside of Stripe.
  * `pdf` The link to download the PDF of the credit note.
  * `post_payment_amount` The amount of the credit note that was refunded to the customer, credited to the customer's balance, credited outside of Stripe, or any combination thereof.
  * `pre_payment_amount` The amount of the credit note by which the invoice's `amount_remaining` and `amount_due` were reduced.
  * `pretax_credit_amounts` The pretax credit amounts (ex: discount, credit grants, etc) for all line items.
  * `reason` Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory`
  * `refunds` Refunds related to this credit note.
  * `shipping_cost` The details of the cost of shipping, including the ShippingRate applied to the invoice.
  * `status` Status of this credit note, one of `issued` or `void`. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding).
  * `subtotal` The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding exclusive tax and invoice level discounts.
  * `subtotal_excluding_tax` The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding all tax and invoice level discounts.
  * `total` The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax and all discount.
  * `total_excluding_tax` The integer amount in cents (or local equivalent) representing the total amount of the credit note, excluding tax, but including discounts.
  * `total_taxes` The aggregate tax information for all line items.
  * `type` Type of this credit note, one of `pre_payment` or `post_payment`. A `pre_payment` credit note means it was issued when the invoice was open. A `post_payment` credit note means it was issued when the invoice was paid.
  * `voided_at` The time that the credit note was voided.

# `tax_amounts`

```elixir
@type tax_amounts() :: %{
  optional(:amount) =&gt; integer(),
  optional(:tax_rate) =&gt; binary(),
  optional(:taxable_amount) =&gt; integer()
}
```

# `create`

```elixir
@spec create(
  params :: %{
    optional(:amount) =&gt; integer(),
    optional(:credit_amount) =&gt; integer(),
    optional(:effective_at) =&gt; integer(),
    optional(:email_type) =&gt; :credit_note | :none,
    optional(:expand) =&gt; [binary()],
    optional(:invoice) =&gt; binary(),
    optional(:lines) =&gt; [lines()],
    optional(:memo) =&gt; binary(),
    optional(:metadata) =&gt; %{optional(binary()) =&gt; binary()},
    optional(:out_of_band_amount) =&gt; integer(),
    optional(:reason) =&gt;
      :duplicate | :fraudulent | :order_change | :product_unsatisfactory,
    optional(:refund_amount) =&gt; integer(),
    optional(:refunds) =&gt; [refunds()],
    optional(:shipping_cost) =&gt; shipping_cost()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
```

<p>Issue a credit note to adjust the amount of a finalized invoice. A credit note will first reduce the invoice’s <code>amount_remaining</code> (and <code>amount_due</code>), but not below zero.
This amount is indicated by the credit note’s <code>pre_payment_amount</code>. The excess amount is indicated by <code>post_payment_amount</code>, and it can result in any combination of the following:</p>

<ul>
<li>Refunds: create a new refund (using <code>refund_amount</code>) or link existing refunds (using <code>refunds</code>).</li>
<li>Customer balance credit: credit the customer’s balance (using <code>credit_amount</code>) which will be automatically applied to their next invoice when it’s finalized.</li>
<li>Outside of Stripe credit: record the amount that is or will be credited outside of Stripe (using <code>out_of_band_amount</code>).</li>
</ul>

<p>The sum of refunds, customer balance credits, and outside of Stripe credits must equal the <code>post_payment_amount</code>.</p>

<p>You may issue multiple credit notes for an invoice. Each credit note may increment the invoice’s <code>pre_payment_credit_notes_amount</code>,
<code>post_payment_credit_notes_amount</code>, or both, depending on the invoice’s <code>amount_remaining</code> at the time of credit note creation.</p>

#### Details

 * Method: `post`
 * Path: `/v1/credit_notes`

# `list`

```elixir
@spec list(
  params :: %{
    optional(:created) =&gt; created() | integer(),
    optional(:customer) =&gt; binary(),
    optional(:ending_before) =&gt; binary(),
    optional(:expand) =&gt; [binary()],
    optional(:invoice) =&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 credit notes.</p>

#### Details

 * Method: `get`
 * Path: `/v1/credit_notes`

# `preview`

```elixir
@spec preview(
  params :: %{
    optional(:amount) =&gt; integer(),
    optional(:credit_amount) =&gt; integer(),
    optional(:effective_at) =&gt; integer(),
    optional(:email_type) =&gt; :credit_note | :none,
    optional(:expand) =&gt; [binary()],
    optional(:invoice) =&gt; binary(),
    optional(:lines) =&gt; [lines()],
    optional(:memo) =&gt; binary(),
    optional(:metadata) =&gt; %{optional(binary()) =&gt; binary()},
    optional(:out_of_band_amount) =&gt; integer(),
    optional(:reason) =&gt;
      :duplicate | :fraudulent | :order_change | :product_unsatisfactory,
    optional(:refund_amount) =&gt; integer(),
    optional(:refunds) =&gt; [refunds()],
    optional(:shipping_cost) =&gt; shipping_cost()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
```

<p>Get a preview of a credit note without creating it.</p>

#### Details

 * Method: `get`
 * Path: `/v1/credit_notes/preview`

# `preview_lines`

```elixir
@spec preview_lines(
  params :: %{
    optional(:amount) =&gt; integer(),
    optional(:credit_amount) =&gt; integer(),
    optional(:effective_at) =&gt; integer(),
    optional(:email_type) =&gt; :credit_note | :none,
    optional(:ending_before) =&gt; binary(),
    optional(:expand) =&gt; [binary()],
    optional(:invoice) =&gt; binary(),
    optional(:limit) =&gt; integer(),
    optional(:lines) =&gt; [lines()],
    optional(:memo) =&gt; binary(),
    optional(:metadata) =&gt; %{optional(binary()) =&gt; binary()},
    optional(:out_of_band_amount) =&gt; integer(),
    optional(:reason) =&gt;
      :duplicate | :fraudulent | :order_change | :product_unsatisfactory,
    optional(:refund_amount) =&gt; integer(),
    optional(:refunds) =&gt; [refunds()],
    optional(:shipping_cost) =&gt; shipping_cost(),
    optional(:starting_after) =&gt; binary()
  },
  opts :: Keyword.t()
) ::
  {:ok, Stripe.List.t(Stripe.CreditNoteLineItem.t())}
  | {:error, Stripe.ApiErrors.t()}
  | {:error, term()}
```

<p>When retrieving a credit note preview, you’ll get a <strong>lines</strong> property containing the first handful of those items. This URL you can retrieve the full (paginated) list of line items.</p>

#### Details

 * Method: `get`
 * Path: `/v1/credit_notes/preview/lines`

# `retrieve`

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

<p>Retrieves the credit note object with the given identifier.</p>

#### Details

 * Method: `get`
 * Path: `/v1/credit_notes/{id}`

# `update`

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

<p>Updates an existing credit note.</p>

#### Details

 * Method: `post`
 * Path: `/v1/credit_notes/{id}`

# `void_credit_note`

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

<p>Marks a credit note as void. Learn more about <a href="/docs/billing/invoices/credit-notes#voiding">voiding credit notes</a>.</p>

#### Details

 * Method: `post`
 * Path: `/v1/credit_notes/{id}/void`

---

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