View Source Stripe.Invoiceitem (stripity_stripe v3.2.0)

Invoice Items represent the component lines of an invoice. An invoice item is added to an invoice by creating or updating it with an invoice field, at which point it will be included as an invoice line item within invoice.lines.

Invoice Items can be created before you are ready to actually send the invoice. This can be particularly useful when combined with a subscription. Sometimes you want to add a charge or credit to a customer, but actually charge or credit the customer’s card only at the end of a regular billing cycle. This is useful for combining several charges (to minimize per-transaction fees), or for having Stripe tabulate your usage-based billing totals.

Related guides: Integrate with the Invoicing API, Subscription Invoices.

Summary

Types

The period associated with this invoice item. When set to different values, the period will be rendered on the invoice. If you have Stripe Revenue Recognition enabled, the period will be used to recognize and defer revenue. See the Revenue Recognition documentation for details.

Data used to generate a new Price object inline.

t()

The invoiceitem type.

Functions

Creates an item to be added to a draft invoice (up to 250 items per invoice). If no invoice is specified, the item will be on the next invoice created for the customer specified.

Deletes an invoice item, removing it from an invoice. Deleting invoice items is only possible when they’re not attached to invoices, or if it’s attached to a draft invoice.

Returns a list of your invoice items. Invoice items are returned sorted by creation date, with the most recently created invoice items appearing first.

Retrieves the invoice item with the given ID.

Updates the amount or description of an invoice item on an upcoming invoice. Updating an invoice item is only possible before the invoice it’s attached to is closed.

Types

@type created() :: %{
  optional(:gt) => integer(),
  optional(:gte) => integer(),
  optional(:lt) => integer(),
  optional(:lte) => integer()
}
@type discounts() :: %{optional(:coupon) => binary(), optional(:discount) => binary()}
@type period() :: %{optional(:end) => integer(), optional(:start) => integer()}

The period associated with this invoice item. When set to different values, the period will be rendered on the invoice. If you have Stripe Revenue Recognition enabled, the period will be used to recognize and defer revenue. See the Revenue Recognition documentation for details.

@type price_data() :: %{
  optional(:currency) => binary(),
  optional(:product) => binary(),
  optional(:tax_behavior) => :exclusive | :inclusive | :unspecified,
  optional(:unit_amount) => integer(),
  optional(:unit_amount_decimal) => binary()
}

Data used to generate a new Price object inline.

@type t() :: %Stripe.Invoiceitem{
  amount: integer(),
  currency: binary(),
  customer: binary() | Stripe.Customer.t() | Stripe.DeletedCustomer.t(),
  date: integer(),
  description: binary() | nil,
  discountable: boolean(),
  discounts: term() | nil,
  id: binary(),
  invoice: (binary() | Stripe.Invoice.t()) | nil,
  livemode: boolean(),
  metadata: term() | nil,
  object: binary(),
  period: term(),
  plan: Stripe.Plan.t() | nil,
  price: Stripe.Price.t() | nil,
  proration: boolean(),
  quantity: integer(),
  subscription: (binary() | Stripe.Subscription.t()) | nil,
  subscription_item: binary(),
  tax_rates: term() | nil,
  test_clock: (binary() | Stripe.TestHelpers.TestClock.t()) | nil,
  unit_amount: integer() | nil,
  unit_amount_decimal: binary() | nil
}

The invoiceitem type.

  • amount Amount (in the currency specified) of the invoice item. This should always be equal to unit_amount * quantity.
  • currency Three-letter ISO currency code, in lowercase. Must be a supported currency.
  • customer The ID of the customer who will be billed when this invoice item is billed.
  • date Time at which the object was created. Measured in seconds since the Unix epoch.
  • description An arbitrary string attached to the object. Often useful for displaying to users.
  • discountable If true, discounts will apply to this invoice item. Always false for prorations.
  • discounts The discounts which apply to the invoice item. Item discounts are applied before invoice discounts. Use expand[]=discounts to expand each discount.
  • id Unique identifier for the object.
  • invoice The ID of the invoice this invoice item belongs to.
  • 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 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.
  • period
  • plan If the invoice item is a proration, the plan of the subscription that the proration was computed for.
  • price The price of the invoice item.
  • proration Whether the invoice item was created automatically as a proration adjustment when the customer switched plans.
  • quantity Quantity of units for the invoice item. If the invoice item is a proration, the quantity of the subscription that the proration was computed for.
  • subscription The subscription that this invoice item has been created for, if any.
  • subscription_item The subscription item that this invoice item has been created for, if any.
  • tax_rates The tax rates which apply to the invoice item. When set, the default_tax_rates on the invoice do not apply to this invoice item.
  • test_clock ID of the test clock this invoice item belongs to.
  • unit_amount Unit amount (in the currency specified) of the invoice item.
  • unit_amount_decimal Same as unit_amount, but contains a decimal value with at most 12 decimal places.

Functions

Link to this function

create(params \\ %{}, opts \\ [])

View Source
@spec create(
  params :: %{
    optional(:amount) => integer(),
    optional(:currency) => binary(),
    optional(:customer) => binary(),
    optional(:description) => binary(),
    optional(:discountable) => boolean(),
    optional(:discounts) => [discounts()] | binary(),
    optional(:expand) => [binary()],
    optional(:invoice) => binary(),
    optional(:metadata) => %{optional(binary()) => binary()} | binary(),
    optional(:period) => period(),
    optional(:price) => binary(),
    optional(:price_data) => price_data(),
    optional(:quantity) => integer(),
    optional(:subscription) => binary(),
    optional(:tax_behavior) => :exclusive | :inclusive | :unspecified,
    optional(:tax_code) => binary() | binary(),
    optional(:tax_rates) => [binary()],
    optional(:unit_amount) => integer(),
    optional(:unit_amount_decimal) => binary()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Creates an item to be added to a draft invoice (up to 250 items per invoice). If no invoice is specified, the item will be on the next invoice created for the customer specified.

Details

  • Method: post
  • Path: /v1/invoiceitems
Link to this function

delete(invoiceitem, opts \\ [])

View Source
@spec delete(invoiceitem :: binary(), opts :: Keyword.t()) ::
  {:ok, Stripe.DeletedInvoiceitem.t()}
  | {:error, Stripe.ApiErrors.t()}
  | {:error, term()}

Deletes an invoice item, removing it from an invoice. Deleting invoice items is only possible when they’re not attached to invoices, or if it’s attached to a draft invoice.

Details

  • Method: delete
  • Path: /v1/invoiceitems/{invoiceitem}
Link to this function

list(params \\ %{}, opts \\ [])

View Source
@spec list(
  params :: %{
    optional(:created) => created() | integer(),
    optional(:customer) => binary(),
    optional(:ending_before) => binary(),
    optional(:expand) => [binary()],
    optional(:invoice) => binary(),
    optional(:limit) => integer(),
    optional(:pending) => boolean(),
    optional(:starting_after) => binary()
  },
  opts :: Keyword.t()
) ::
  {:ok, Stripe.List.t(t())} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Returns a list of your invoice items. Invoice items are returned sorted by creation date, with the most recently created invoice items appearing first.

Details

  • Method: get
  • Path: /v1/invoiceitems
Link to this function

retrieve(invoiceitem, params \\ %{}, opts \\ [])

View Source
@spec retrieve(
  invoiceitem :: binary(),
  params :: %{optional(:expand) => [binary()]},
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Retrieves the invoice item with the given ID.

Details

  • Method: get
  • Path: /v1/invoiceitems/{invoiceitem}
Link to this function

update(invoiceitem, params \\ %{}, opts \\ [])

View Source
@spec update(
  invoiceitem :: binary(),
  params :: %{
    optional(:amount) => integer(),
    optional(:description) => binary(),
    optional(:discountable) => boolean(),
    optional(:discounts) => [discounts()] | binary(),
    optional(:expand) => [binary()],
    optional(:metadata) => %{optional(binary()) => binary()} | binary(),
    optional(:period) => period(),
    optional(:price) => binary(),
    optional(:price_data) => price_data(),
    optional(:quantity) => integer(),
    optional(:tax_behavior) => :exclusive | :inclusive | :unspecified,
    optional(:tax_code) => binary() | binary(),
    optional(:tax_rates) => [binary()] | binary(),
    optional(:unit_amount) => integer(),
    optional(:unit_amount_decimal) => binary()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Updates the amount or description of an invoice item on an upcoming invoice. Updating an invoice item is only possible before the invoice it’s attached to is closed.

Details

  • Method: post
  • Path: /v1/invoiceitems/{invoiceitem}