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

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

Defined Under Namespace

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

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).



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

def amount
  @amount
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).



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

def currency
  @currency
end

#descriptionObject (readonly)

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



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

def description
  @description
end

#discount_amountsObject (readonly)

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



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

def discount_amounts
  @discount_amounts
end

#discountableObject (readonly)

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



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

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.



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

def discounts
  @discounts
end

#idObject (readonly)

Unique identifier for the object.



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

def id
  @id
end

#invoiceObject (readonly)

The ID of the invoice that contains this line item.



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

def invoice
  @invoice
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.



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

def livemode
  @livemode
end

#margin_amountsObject (readonly)

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



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

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.



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

def margins
  @margins
end

#metadataObject (readonly)

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



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

def 
  @metadata
end

#objectObject (readonly)

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



426
427
428
# File 'lib/stripe/resources/invoice_line_item.rb', line 426

def object
  @object
end

#parentObject (readonly)

The parent that generated this line item.



428
429
430
# File 'lib/stripe/resources/invoice_line_item.rb', line 428

def parent
  @parent
end

#periodObject (readonly)

Attribute for field period



430
431
432
# File 'lib/stripe/resources/invoice_line_item.rb', line 430

def period
  @period
end

#pretax_credit_amountsObject (readonly)

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



432
433
434
# File 'lib/stripe/resources/invoice_line_item.rb', line 432

def pretax_credit_amounts
  @pretax_credit_amounts
end

#pricingObject (readonly)

The pricing information of the line item.



434
435
436
# File 'lib/stripe/resources/invoice_line_item.rb', line 434

def pricing
  @pricing
end

#quantityObject (readonly)

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



436
437
438
# File 'lib/stripe/resources/invoice_line_item.rb', line 436

def quantity
  @quantity
end

#subscriptionObject (readonly)

Attribute for field subscription



438
439
440
# File 'lib/stripe/resources/invoice_line_item.rb', line 438

def subscription
  @subscription
end

#subtotalObject (readonly)

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



440
441
442
# File 'lib/stripe/resources/invoice_line_item.rb', line 440

def subtotal
  @subtotal
end

#tax_calculation_referenceObject (readonly)

The tax calculation identifiers of the line item.



442
443
444
# File 'lib/stripe/resources/invoice_line_item.rb', line 442

def tax_calculation_reference
  @tax_calculation_reference
end

#taxesObject (readonly)

The tax information of the line item.



444
445
446
# File 'lib/stripe/resources/invoice_line_item.rb', line 444

def taxes
  @taxes
end

Class Method Details

.field_remappingsObject



472
473
474
# File 'lib/stripe/resources/invoice_line_item.rb', line 472

def self.field_remappings
  @field_remappings = {}
end

.inner_class_typesObject



459
460
461
462
463
464
465
466
467
468
469
470
# File 'lib/stripe/resources/invoice_line_item.rb', line 459

def self.inner_class_types
  @inner_class_types = {
    discount_amounts: DiscountAmount,
    margin_amounts: MarginAmount,
    parent: Parent,
    period: Period,
    pretax_credit_amounts: PretaxCreditAmount,
    pricing: Pricing,
    tax_calculation_reference: TaxCalculationReference,
    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.



450
451
452
453
454
455
456
457
# File 'lib/stripe/resources/invoice_line_item.rb', line 450

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