Class: Stripe::InvoiceLineItem

Inherits:
StripeObject 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](stripe.com/docs/api/invoices) and only exist within the context of an invoice.

Each line item is backed by either an [invoice item](stripe.com/docs/api/invoiceitems) or a [subscription item](stripe.com/docs/api/subscription_items).

Defined Under Namespace

Classes: DiscountAmount, MarginAmount, Period, PretaxCreditAmount, ProrationDetails, TaxAmount, UpdateParams

Constant Summary collapse

OBJECT_NAME =
"line_item"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary collapse

Attributes inherited from StripeObject

#last_response

Class Method Summary collapse

Methods included from APIOperations::Save

included, #save

Methods inherited from StripeObject

#==, #[], #[]=, 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).



342
343
344
# File 'lib/stripe/resources/invoice_line_item.rb', line 342

def amount
  @amount
end

#amount_excluding_taxObject (readonly)

The integer amount in cents (or local equivalent) representing the amount for this line item, excluding all tax and discounts.



345
346
347
# File 'lib/stripe/resources/invoice_line_item.rb', line 345

def amount_excluding_tax
  @amount_excluding_tax
end

#currencyObject (readonly)

Three-letter [ISO currency code](www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](stripe.com/docs/currencies).



348
349
350
# File 'lib/stripe/resources/invoice_line_item.rb', line 348

def currency
  @currency
end

#descriptionObject (readonly)

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



351
352
353
# File 'lib/stripe/resources/invoice_line_item.rb', line 351

def description
  @description
end

#discount_amountsObject (readonly)

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



354
355
356
# File 'lib/stripe/resources/invoice_line_item.rb', line 354

def discount_amounts
  @discount_amounts
end

#discountableObject (readonly)

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



357
358
359
# File 'lib/stripe/resources/invoice_line_item.rb', line 357

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.



360
361
362
# File 'lib/stripe/resources/invoice_line_item.rb', line 360

def discounts
  @discounts
end

#idObject (readonly)

Unique identifier for the object.



363
364
365
# File 'lib/stripe/resources/invoice_line_item.rb', line 363

def id
  @id
end

#invoiceObject (readonly)

The ID of the invoice that contains this line item.



366
367
368
# File 'lib/stripe/resources/invoice_line_item.rb', line 366

def invoice
  @invoice
end

#invoice_itemObject (readonly)

The ID of the [invoice item](stripe.com/docs/api/invoiceitems) associated with this line item if any.



369
370
371
# File 'lib/stripe/resources/invoice_line_item.rb', line 369

def invoice_item
  @invoice_item
end

#livemodeObject (readonly)

Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.



372
373
374
# File 'lib/stripe/resources/invoice_line_item.rb', line 372

def livemode
  @livemode
end

#margin_amountsObject (readonly)

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



375
376
377
# File 'lib/stripe/resources/invoice_line_item.rb', line 375

def margin_amounts
  @margin_amounts
end

#marginsObject (readonly)

The margins applied to the line item. When set, the ‘default_margins` on the invoice do not apply to the line item. Use `expand[]=margins` to expand each margin.



378
379
380
# File 'lib/stripe/resources/invoice_line_item.rb', line 378

def margins
  @margins
end

#metadataObject (readonly)

Set of [key-value pairs](stripe.com/docs/api/metadata) 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.



381
382
383
# File 'lib/stripe/resources/invoice_line_item.rb', line 381

def 
  @metadata
end

#objectObject (readonly)

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



384
385
386
# File 'lib/stripe/resources/invoice_line_item.rb', line 384

def object
  @object
end

#periodObject (readonly)

Attribute for field period



387
388
389
# File 'lib/stripe/resources/invoice_line_item.rb', line 387

def period
  @period
end

#planObject (readonly)

The plan of the subscription, if the line item is a subscription or a proration.



390
391
392
# File 'lib/stripe/resources/invoice_line_item.rb', line 390

def plan
  @plan
end

#pretax_credit_amountsObject (readonly)

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



393
394
395
# File 'lib/stripe/resources/invoice_line_item.rb', line 393

def pretax_credit_amounts
  @pretax_credit_amounts
end

#priceObject (readonly)

The price of the line item.



396
397
398
# File 'lib/stripe/resources/invoice_line_item.rb', line 396

def price
  @price
end

#prorationObject (readonly)

Whether this is a proration.



399
400
401
# File 'lib/stripe/resources/invoice_line_item.rb', line 399

def proration
  @proration
end

#proration_detailsObject (readonly)

Additional details for proration line items



402
403
404
# File 'lib/stripe/resources/invoice_line_item.rb', line 402

def proration_details
  @proration_details
end

#quantityObject (readonly)

The quantity of the subscription, if the line item is a subscription or a proration.



405
406
407
# File 'lib/stripe/resources/invoice_line_item.rb', line 405

def quantity
  @quantity
end

#subscriptionObject (readonly)

The subscription that the invoice item pertains to, if any.



408
409
410
# File 'lib/stripe/resources/invoice_line_item.rb', line 408

def subscription
  @subscription
end

#subscription_itemObject (readonly)

The subscription item that generated this line item. Left empty if the line item is not an explicit result of a subscription.



411
412
413
# File 'lib/stripe/resources/invoice_line_item.rb', line 411

def subscription_item
  @subscription_item
end

#tax_amountsObject (readonly)

The amount of tax calculated per tax rate for this line item



414
415
416
# File 'lib/stripe/resources/invoice_line_item.rb', line 414

def tax_amounts
  @tax_amounts
end

#tax_ratesObject (readonly)

The tax rates which apply to the line item.



417
418
419
# File 'lib/stripe/resources/invoice_line_item.rb', line 417

def tax_rates
  @tax_rates
end

#typeObject (readonly)

A string identifying the type of the source of this line item, either an ‘invoiceitem` or a `subscription`.



420
421
422
# File 'lib/stripe/resources/invoice_line_item.rb', line 420

def type
  @type
end

#unit_amount_excluding_taxObject (readonly)

The amount in cents (or local equivalent) representing the unit amount for this line item, excluding all tax and discounts.



423
424
425
# File 'lib/stripe/resources/invoice_line_item.rb', line 423

def unit_amount_excluding_tax
  @unit_amount_excluding_tax
end

Class Method Details

.object_nameObject



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

def self.object_name
  "line_item"
end

.update(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.



429
430
431
432
433
434
435
436
# File 'lib/stripe/resources/invoice_line_item.rb', line 429

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