LatticeStripe.Invoice.LineItem (LatticeStripe v1.7.2)

Copy Markdown View Source

Represents a line item on a Stripe Invoice.

InvoiceItem vs Invoice Line Item

These are distinct Stripe objects and should not be confused:

  • LatticeStripe.InvoiceItem — a standalone billable item that gets attached to an invoice. Has its own CRUD surface (/v1/invoiceitems). Identified by ii_... IDs.
  • LatticeStripe.Invoice.LineItem — a read-only view of a line item as it appears on a finalized invoice. Accessed via /v1/invoices/:id/lines. Identified by il_... IDs.

Invoice line items are returned inside Invoice objects and from LatticeStripe.Invoice.list_line_items/3. They cannot be created directly.

Fields

  • id - Line item ID (il_...)
  • object - Always "line_item"
  • amount - Amount in smallest currency unit (e.g., cents)
  • amount_excluding_tax - Amount before taxes
  • currency - Three-letter ISO currency code
  • description - Human-readable description
  • discount_amounts - List of discount amount objects
  • discountable - Whether discounts apply to this line item
  • discounts - List of discount IDs or objects
  • invoice - Parent invoice ID
  • invoice_item - InvoiceItem ID (ii_...) if this line item originated from an InvoiceItem
  • livemode - Whether the object exists in live mode
  • metadata - Set of key-value pairs
  • period - Billing period map (%{"start" => ..., "end" => ...})
  • plan - Plan object if the line item is from a subscription plan
  • price - Price object associated with this line item
  • proration - Whether this line item is a proration
  • proration_details - Details about the proration
  • quantity - Quantity for this line item
  • subscription - Subscription ID if applicable
  • subscription_item - SubscriptionItem ID if applicable
  • tax_amounts - List of tax amount objects
  • tax_rates - List of tax rate objects
  • type - Type of the line item: "invoiceitem" or "subscription"
  • unit_amount_excluding_tax - Unit amount excluding tax as a string decimal
  • extra - Unknown fields from Stripe not yet in this struct

Stripe API Reference

See the Stripe Invoice line item object for field definitions.

Summary

Types

t()

A line item on a Stripe Invoice.

Functions

Converts a decoded Stripe API map to a %LineItem{} struct.

Types

t()

@type t() :: %LatticeStripe.Invoice.LineItem{
  amount: integer() | nil,
  amount_excluding_tax: integer() | nil,
  currency: String.t() | nil,
  description: String.t() | nil,
  discount_amounts: list() | nil,
  discountable: boolean() | nil,
  discounts: list() | nil,
  extra: map(),
  id: String.t() | nil,
  invoice: String.t() | nil,
  invoice_item: String.t() | nil,
  livemode: boolean() | nil,
  metadata: map() | nil,
  object: String.t(),
  period: map() | nil,
  plan: map() | nil,
  price: map() | nil,
  proration: boolean() | nil,
  proration_details: map() | nil,
  quantity: integer() | nil,
  subscription: String.t() | nil,
  subscription_item: String.t() | nil,
  tax_amounts: list() | nil,
  tax_rates: list() | nil,
  type: String.t() | nil,
  unit_amount_excluding_tax: String.t() | nil
}

A line item on a Stripe Invoice.

Accessed via LatticeStripe.Invoice.list_line_items/3 or returned nested in Invoice objects. Cannot be created directly.

See Stripe Invoice line items for field definitions.

Functions

from_map(map)

@spec from_map(map() | nil) :: t() | nil

Converts a decoded Stripe API map to a %LineItem{} struct.

Maps all known line item fields. Any unrecognized fields are collected into the extra map so no data is silently lost.

Returns nil when given nil.

Example

iex> LatticeStripe.Invoice.LineItem.from_map(%{
...>   "id" => "il_test123",
...>   "object" => "line_item",
...>   "amount" => 2000,
...>   "currency" => "usd"
...> })
%LatticeStripe.Invoice.LineItem{id: "il_test123", amount: 2000, currency: "usd", ...}