Class: Stripe::InvoiceLineItem

Inherits:
APIResource show all
Includes:
APIOperations::Save
Defined in:
lib/stripe/resources/invoice_line_item.rb

Overview

Invoice Line Items represent the individual lines within an invoice and only exist within the context of an invoice.

Each line item is backed by either an invoice item or a subscription item.

Defined Under Namespace

Classes: DiscountAmount, Parent, Period, PretaxCreditAmount, Pricing, Tax

Constant Summary collapse

OBJECT_NAME =
"line_item"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary collapse

Attributes inherited from APIResource

#save_with_parent

Attributes inherited from StripeObject

#last_response

Class Method Summary collapse

Methods included from APIOperations::Save

included, #save

Methods inherited from APIResource

class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource

Methods included from APIOperations::Request

included

Methods inherited from StripeObject

#==, #[], #[]=, #_get_inner_class_type, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values

Constructor Details

This class inherits a constructor from Stripe::StripeObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject

Instance Attribute Details

#amountObject (readonly)

The amount, in cents (or local equivalent).



246
247
248
# File 'lib/stripe/resources/invoice_line_item.rb', line 246

def amount
  @amount
end

#currencyObject (readonly)

Three-letter ISO currency code, in lowercase. Must be a supported currency.



248
249
250
# File 'lib/stripe/resources/invoice_line_item.rb', line 248

def currency
  @currency
end

#descriptionObject (readonly)

An arbitrary string attached to the object. Often useful for displaying to users.



250
251
252
# File 'lib/stripe/resources/invoice_line_item.rb', line 250

def description
  @description
end

#discount_amountsObject (readonly)

The amount of discount calculated per discount for this line item.



252
253
254
# File 'lib/stripe/resources/invoice_line_item.rb', line 252

def discount_amounts
  @discount_amounts
end

#discountableObject (readonly)

If true, discounts will apply to this line item. Always false for prorations.



254
255
256
# File 'lib/stripe/resources/invoice_line_item.rb', line 254

def discountable
  @discountable
end

#discountsObject (readonly)

The discounts applied to the invoice line item. Line item discounts are applied before invoice discounts. Use expand[]=discounts to expand each discount.



256
257
258
# File 'lib/stripe/resources/invoice_line_item.rb', line 256

def discounts
  @discounts
end

#idObject (readonly)

Unique identifier for the object.



258
259
260
# File 'lib/stripe/resources/invoice_line_item.rb', line 258

def id
  @id
end

#invoiceObject (readonly)

The ID of the invoice that contains this line item.



260
261
262
# File 'lib/stripe/resources/invoice_line_item.rb', line 260

def invoice
  @invoice
end

#livemodeObject (readonly)

If the object exists in live mode, the value is true. If the object exists in test mode, the value is false.



262
263
264
# File 'lib/stripe/resources/invoice_line_item.rb', line 262

def livemode
  @livemode
end

#metadataObject (readonly)

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. Note that for line items with type=subscription, metadata reflects the current metadata from the subscription associated with the line item, unless the invoice line was directly updated with different metadata after creation.



264
265
266
# File 'lib/stripe/resources/invoice_line_item.rb', line 264

def 
  
end

#objectObject (readonly)

String representing the object's type. Objects of the same type share the same value.



266
267
268
# File 'lib/stripe/resources/invoice_line_item.rb', line 266

def object
  @object
end

#parentObject (readonly)

The parent that generated this line item.



268
269
270
# File 'lib/stripe/resources/invoice_line_item.rb', line 268

def parent
  @parent
end

#periodObject (readonly)

Attribute for field period



270
271
272
# File 'lib/stripe/resources/invoice_line_item.rb', line 270

def period
  @period
end

#pretax_credit_amountsObject (readonly)

Contains pretax credit amounts (ex: discount, credit grants, etc) that apply to this line item.



272
273
274
# File 'lib/stripe/resources/invoice_line_item.rb', line 272

def pretax_credit_amounts
  @pretax_credit_amounts
end

#pricingObject (readonly)

The pricing information of the line item.



274
275
276
# File 'lib/stripe/resources/invoice_line_item.rb', line 274

def pricing
  @pricing
end

#quantityObject (readonly)

Quantity of units for the invoice line item in integer format, with any decimal precision truncated. For the line item's full-precision decimal quantity, use quantity_decimal. This field will be deprecated in favor of quantity_decimal in a future version. If the line item is a proration or subscription, the quantity of the subscription that the proration was computed for.



276
277
278
# File 'lib/stripe/resources/invoice_line_item.rb', line 276

def quantity
  @quantity
end

#quantity_decimalObject (readonly)

Non-negative decimal with at most 12 decimal places. The quantity of units for the line item.



278
279
280
# File 'lib/stripe/resources/invoice_line_item.rb', line 278

def quantity_decimal
  @quantity_decimal
end

#subscriptionObject (readonly)

Attribute for field subscription



280
281
282
# File 'lib/stripe/resources/invoice_line_item.rb', line 280

def subscription
  @subscription
end

#subtotalObject (readonly)

The subtotal of the line item, in cents (or local equivalent), before any discounts or taxes.



282
283
284
# File 'lib/stripe/resources/invoice_line_item.rb', line 282

def subtotal
  @subtotal
end

#taxesObject (readonly)

The tax information of the line item.



284
285
286
# File 'lib/stripe/resources/invoice_line_item.rb', line 284

def taxes
  @taxes
end

Class Method Details

.field_encodingsObject



314
315
316
317
318
319
# File 'lib/stripe/resources/invoice_line_item.rb', line 314

def self.field_encodings
  @field_encodings = {
    pricing: { kind: :object, fields: { unit_amount_decimal: :decimal_string } },
    quantity_decimal: :decimal_string,
  }
end

.field_remappingsObject



310
311
312
# File 'lib/stripe/resources/invoice_line_item.rb', line 310

def self.field_remappings
  @field_remappings = {}
end

.inner_class_typesObject



299
300
301
302
303
304
305
306
307
308
# File 'lib/stripe/resources/invoice_line_item.rb', line 299

def self.inner_class_types
  @inner_class_types = {
    discount_amounts: DiscountAmount,
    parent: Parent,
    period: Period,
    pretax_credit_amounts: PretaxCreditAmount,
    pricing: Pricing,
    taxes: Tax,
  }
end

.object_nameObject



12
13
14
# File 'lib/stripe/resources/invoice_line_item.rb', line 12

def self.object_name
  "line_item"
end

.update(invoice, line_item_id, params = {}, opts = {}) ⇒ Object

Updates an invoice's line item. Some fields, such as tax_amounts, only live on the invoice line item, so they can only be updated through this endpoint. Other fields, such as amount, live on both the invoice item and the invoice line item, so updates on this endpoint will propagate to the invoice item as well. Updating an invoice's line item is only possible before the invoice is finalized.



290
291
292
293
294
295
296
297
# File 'lib/stripe/resources/invoice_line_item.rb', line 290

def self.update(invoice, line_item_id, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/invoices/%<invoice>s/lines/%<line_item_id>s", { invoice: CGI.escape(invoice), line_item_id: CGI.escape(line_item_id) }),
    params: params,
    opts: opts
  )
end