Class: Stripe::InvoiceLineItem
- Inherits:
-
StripeObject
- Object
- StripeObject
- Stripe::InvoiceLineItem
- 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
Constant Summary collapse
- OBJECT_NAME =
"line_item"
Constants inherited from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
The amount, in cents (or local equivalent).
-
#amount_excluding_tax ⇒ Object
readonly
The integer amount in cents (or local equivalent) representing the amount for this line item, excluding all tax and discounts.
-
#currency ⇒ Object
readonly
Three-letter [ISO currency code](www.iso.org/iso-4217-currency-codes.html), in lowercase.
-
#description ⇒ Object
readonly
An arbitrary string attached to the object.
-
#discount_amounts ⇒ Object
readonly
The amount of discount calculated per discount for this line item.
-
#discountable ⇒ Object
readonly
If true, discounts will apply to this line item.
-
#discounts ⇒ Object
readonly
The discounts applied to the invoice line item.
-
#id ⇒ Object
readonly
Unique identifier for the object.
-
#invoice ⇒ Object
readonly
The ID of the invoice that contains this line item.
-
#invoice_item ⇒ Object
readonly
The ID of the [invoice item](stripe.com/docs/api/invoiceitems) associated with this line item if any.
-
#livemode ⇒ Object
readonly
Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.
-
#margin_amounts ⇒ Object
readonly
The amount of margin calculated per margin for this line item.
-
#margins ⇒ Object
readonly
The margins applied to the line item.
-
#metadata ⇒ Object
readonly
Set of [key-value pairs](stripe.com/docs/api/metadata) that you can attach to an object.
-
#object ⇒ Object
readonly
String representing the object’s type.
-
#period ⇒ Object
readonly
Attribute for field period.
-
#plan ⇒ Object
readonly
The plan of the subscription, if the line item is a subscription or a proration.
-
#pretax_credit_amounts ⇒ Object
readonly
Contains pretax credit amounts (ex: discount, credit grants, etc) that apply to this line item.
-
#price ⇒ Object
readonly
The price of the line item.
-
#proration ⇒ Object
readonly
Whether this is a proration.
-
#proration_details ⇒ Object
readonly
Additional details for proration line items.
-
#quantity ⇒ Object
readonly
The quantity of the subscription, if the line item is a subscription or a proration.
-
#subscription ⇒ Object
readonly
The subscription that the invoice item pertains to, if any.
-
#subscription_item ⇒ Object
readonly
The subscription item that generated this line item.
-
#tax_amounts ⇒ Object
readonly
The amount of tax calculated per tax rate for this line item.
-
#tax_rates ⇒ Object
readonly
The tax rates which apply to the line item.
-
#type ⇒ Object
readonly
A string identifying the type of the source of this line item, either an ‘invoiceitem` or a `subscription`.
-
#unit_amount_excluding_tax ⇒ Object
readonly
The amount in cents (or local equivalent) representing the unit amount for this line item, excluding all tax and discounts.
Attributes inherited from StripeObject
Class Method Summary collapse
- .object_name ⇒ Object
-
.update(id, params = {}, opts = {}) ⇒ Object
Updates an invoice’s line item.
Methods included from APIOperations::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
#amount ⇒ Object (readonly)
The amount, in cents (or local equivalent).
43 44 45 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 43 def amount @amount end |
#amount_excluding_tax ⇒ Object (readonly)
The integer amount in cents (or local equivalent) representing the amount for this line item, excluding all tax and discounts.
45 46 47 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 45 def amount_excluding_tax @amount_excluding_tax end |
#currency ⇒ Object (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).
47 48 49 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 47 def currency @currency end |
#description ⇒ Object (readonly)
An arbitrary string attached to the object. Often useful for displaying to users.
49 50 51 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 49 def description @description end |
#discount_amounts ⇒ Object (readonly)
The amount of discount calculated per discount for this line item.
51 52 53 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 51 def discount_amounts @discount_amounts end |
#discountable ⇒ Object (readonly)
If true, discounts will apply to this line item. Always false for prorations.
53 54 55 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 53 def discountable @discountable end |
#discounts ⇒ Object (readonly)
The discounts applied to the invoice line item. Line item discounts are applied before invoice discounts. Use ‘expand[]=discounts` to expand each discount.
55 56 57 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 55 def discounts @discounts end |
#id ⇒ Object (readonly)
Unique identifier for the object.
57 58 59 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 57 def id @id end |
#invoice ⇒ Object (readonly)
The ID of the invoice that contains this line item.
59 60 61 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 59 def invoice @invoice end |
#invoice_item ⇒ Object (readonly)
The ID of the [invoice item](stripe.com/docs/api/invoiceitems) associated with this line item if any.
61 62 63 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 61 def invoice_item @invoice_item end |
#livemode ⇒ Object (readonly)
Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.
63 64 65 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 63 def livemode @livemode end |
#margin_amounts ⇒ Object (readonly)
The amount of margin calculated per margin for this line item.
65 66 67 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 65 def margin_amounts @margin_amounts end |
#margins ⇒ Object (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.
67 68 69 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 67 def margins @margins end |
#metadata ⇒ Object (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.
69 70 71 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 69 def @metadata end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
71 72 73 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 71 def object @object end |
#period ⇒ Object (readonly)
Attribute for field period
73 74 75 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 73 def period @period end |
#plan ⇒ Object (readonly)
The plan of the subscription, if the line item is a subscription or a proration.
75 76 77 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 75 def plan @plan end |
#pretax_credit_amounts ⇒ Object (readonly)
Contains pretax credit amounts (ex: discount, credit grants, etc) that apply to this line item.
77 78 79 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 77 def pretax_credit_amounts @pretax_credit_amounts end |
#price ⇒ Object (readonly)
The price of the line item.
79 80 81 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 79 def price @price end |
#proration ⇒ Object (readonly)
Whether this is a proration.
81 82 83 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 81 def proration @proration end |
#proration_details ⇒ Object (readonly)
Additional details for proration line items
83 84 85 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 83 def proration_details @proration_details end |
#quantity ⇒ Object (readonly)
The quantity of the subscription, if the line item is a subscription or a proration.
85 86 87 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 85 def quantity @quantity end |
#subscription ⇒ Object (readonly)
The subscription that the invoice item pertains to, if any.
87 88 89 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 87 def subscription @subscription end |
#subscription_item ⇒ Object (readonly)
The subscription item that generated this line item. Left empty if the line item is not an explicit result of a subscription.
89 90 91 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 89 def subscription_item @subscription_item end |
#tax_amounts ⇒ Object (readonly)
The amount of tax calculated per tax rate for this line item
91 92 93 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 91 def tax_amounts @tax_amounts end |
#tax_rates ⇒ Object (readonly)
The tax rates which apply to the line item.
93 94 95 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 93 def tax_rates @tax_rates end |
#type ⇒ Object (readonly)
A string identifying the type of the source of this line item, either an ‘invoiceitem` or a `subscription`.
95 96 97 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 95 def type @type end |
#unit_amount_excluding_tax ⇒ Object (readonly)
The amount in cents (or local equivalent) representing the unit amount for this line item, excluding all tax and discounts.
97 98 99 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 97 def unit_amount_excluding_tax @unit_amount_excluding_tax end |
Class Method Details
.object_name ⇒ Object
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.
103 104 105 106 107 108 109 110 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 103 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 |