LatticeStripe.Checkout.LineItem (LatticeStripe v1.7.0)

Copy Markdown View Source

Represents a line item in a Checkout Session.

Returned by Checkout.Session.list_line_items/4 and Checkout.Session.stream_line_items!/4. Line items cannot be created or fetched independently — they are always accessed in the context of a Checkout Session.

Fields

  • id - Unique identifier for the line item
  • object - Always "item"
  • amount_discount - Total discount amount in the smallest currency unit
  • amount_subtotal - Subtotal amount before taxes and discounts
  • amount_tax - Total tax amount
  • amount_total - Total amount after discounts and taxes
  • currency - Three-letter ISO currency code
  • description - Human-readable description of the item
  • price - The price object associated with this line item
  • quantity - Quantity of the item purchased

Summary

Types

t()

A line item within a Stripe Checkout Session.

Functions

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

Types

t()

@type t() :: %LatticeStripe.Checkout.LineItem{
  amount_discount: integer() | nil,
  amount_subtotal: integer() | nil,
  amount_tax: integer() | nil,
  amount_total: integer() | nil,
  currency: String.t() | nil,
  description: String.t() | nil,
  extra: map(),
  id: String.t() | nil,
  object: String.t(),
  price: map() | nil,
  quantity: integer() | nil
}

A line item within a Stripe Checkout Session.

Line items are accessed through Checkout.Session.list_line_items/4 or Checkout.Session.stream_line_items!/4. They cannot be fetched independently.

See Stripe Checkout Sessions line items for field definitions.

Functions

from_map(map)

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

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.

Example

item = LatticeStripe.Checkout.LineItem.from_map(%{
  "id" => "li_...",
  "object" => "item",
  "description" => "T-Shirt",
  "quantity" => 1,
  "amount_total" => 2000
})