Class: Stripe::InvoiceLineItem
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- 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](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
-
#amount ⇒ Object
readonly
The amount, in cents (or local equivalent).
-
#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.
-
#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](docs.stripe.com/api/metadata) that you can attach to an object.
-
#object ⇒ Object
readonly
String representing the object’s type.
-
#parent ⇒ Object
readonly
The parent that generated this line item.
-
#period ⇒ Object
readonly
Attribute for field period.
-
#pretax_credit_amounts ⇒ Object
readonly
Contains pretax credit amounts (ex: discount, credit grants, etc) that apply to this line item.
-
#pricing ⇒ Object
readonly
The pricing information of the line item.
-
#quantity ⇒ Object
readonly
The quantity of the subscription, if the line item is a subscription or a proration.
-
#subscription ⇒ Object
readonly
Attribute for field subscription.
-
#subtotal ⇒ Object
readonly
The subtotal of the line item, in cents (or local equivalent), before any discounts or taxes.
-
#tax_calculation_reference ⇒ Object
readonly
The tax calculation identifiers of the line item.
-
#taxes ⇒ Object
readonly
The tax information of the line item.
Attributes inherited from APIResource
Attributes inherited from StripeObject
Class Method Summary collapse
- .field_remappings ⇒ Object
- .inner_class_types ⇒ Object
- .object_name ⇒ Object
-
.update(invoice, line_item_id, params = {}, opts = {}) ⇒ Object
Updates an invoice’s line item.
Methods included from APIOperations::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
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
#amount ⇒ Object (readonly)
The amount, in cents (or local equivalent).
274 275 276 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 274 def amount @amount 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).
276 277 278 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 276 def currency @currency end |
#description ⇒ Object (readonly)
An arbitrary string attached to the object. Often useful for displaying to users.
278 279 280 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 278 def description @description end |
#discount_amounts ⇒ Object (readonly)
The amount of discount calculated per discount for this line item.
280 281 282 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 280 def discount_amounts @discount_amounts end |
#discountable ⇒ Object (readonly)
If true, discounts will apply to this line item. Always false for prorations.
282 283 284 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 282 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.
284 285 286 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 284 def discounts @discounts end |
#id ⇒ Object (readonly)
Unique identifier for the object.
286 287 288 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 286 def id @id end |
#invoice ⇒ Object (readonly)
The ID of the invoice that contains this line item.
288 289 290 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 288 def invoice @invoice 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.
290 291 292 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 290 def livemode @livemode end |
#margin_amounts ⇒ Object (readonly)
The amount of margin calculated per margin for this line item.
292 293 294 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 292 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.
294 295 296 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 294 def margins @margins end |
#metadata ⇒ Object (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.
296 297 298 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 296 def @metadata end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
298 299 300 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 298 def object @object end |
#parent ⇒ Object (readonly)
The parent that generated this line item.
300 301 302 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 300 def parent @parent end |
#period ⇒ Object (readonly)
Attribute for field period
302 303 304 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 302 def period @period end |
#pretax_credit_amounts ⇒ Object (readonly)
Contains pretax credit amounts (ex: discount, credit grants, etc) that apply to this line item.
304 305 306 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 304 def pretax_credit_amounts @pretax_credit_amounts end |
#pricing ⇒ Object (readonly)
The pricing information of the line item.
306 307 308 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 306 def pricing @pricing end |
#quantity ⇒ Object (readonly)
The quantity of the subscription, if the line item is a subscription or a proration.
308 309 310 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 308 def quantity @quantity end |
#subscription ⇒ Object (readonly)
Attribute for field subscription
310 311 312 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 310 def subscription @subscription end |
#subtotal ⇒ Object (readonly)
The subtotal of the line item, in cents (or local equivalent), before any discounts or taxes.
312 313 314 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 312 def subtotal @subtotal end |
#tax_calculation_reference ⇒ Object (readonly)
The tax calculation identifiers of the line item.
314 315 316 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 314 def tax_calculation_reference @tax_calculation_reference end |
#taxes ⇒ Object (readonly)
The tax information of the line item.
316 317 318 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 316 def taxes @taxes end |
Class Method Details
.field_remappings ⇒ Object
344 345 346 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 344 def self.field_remappings @field_remappings = {} end |
.inner_class_types ⇒ Object
331 332 333 334 335 336 337 338 339 340 341 342 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 331 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_name ⇒ Object
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.
322 323 324 325 326 327 328 329 |
# File 'lib/stripe/resources/invoice_line_item.rb', line 322 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 |