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 byii_...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 byil_...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 taxescurrency- Three-letter ISO currency codedescription- Human-readable descriptiondiscount_amounts- List of discount amount objectsdiscountable- Whether discounts apply to this line itemdiscounts- List of discount IDs or objectsinvoice- Parent invoice IDinvoice_item- InvoiceItem ID (ii_...) if this line item originated from an InvoiceItemlivemode- Whether the object exists in live modemetadata- Set of key-value pairsperiod- Billing period map (%{"start" => ..., "end" => ...})plan- Plan object if the line item is from a subscription planprice- Price object associated with this line itemproration- Whether this line item is a prorationproration_details- Details about the prorationquantity- Quantity for this line itemsubscription- Subscription ID if applicablesubscription_item- SubscriptionItem ID if applicabletax_amounts- List of tax amount objectstax_rates- List of tax rate objectstype- Type of the line item:"invoiceitem"or"subscription"unit_amount_excluding_tax- Unit amount excluding tax as a string decimalextra- Unknown fields from Stripe not yet in this struct
Stripe API Reference
See the Stripe Invoice line item object for field definitions.
Summary
Functions
Converts a decoded Stripe API map to a %LineItem{} struct.
Types
@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
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", ...}