Class: Stripe::InvoiceItem
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::InvoiceItem
- Extended by:
- APIOperations::Create, APIOperations::List
- Includes:
- APIOperations::Delete, APIOperations::Save
- Defined in:
- lib/stripe/resources/invoice_item.rb
Overview
Invoice Items represent the component lines of an invoice. When you create an invoice item with an invoice field, it is attached to the specified invoice and included as an invoice line item within invoice.lines.
Invoice Items can be created before you are ready to actually send the invoice. This can be particularly useful when combined with a subscription. Sometimes you want to add a charge or credit to a customer, but actually charge or credit the customer's card only at the end of a regular billing cycle. This is useful for combining several charges (to minimize per-transaction fees), or for having Stripe tabulate your usage-based billing totals.
Related guides: Integrate with the Invoicing API, Subscription Invoices.
Defined Under Namespace
Classes: ManagedPayments, Parent, Period, Pricing, ProrationDetails
Constant Summary collapse
- OBJECT_NAME =
"invoiceitem"
Constants inherited from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Amount (in the
currencyspecified) of the invoice item. -
#currency ⇒ Object
readonly
Three-letter ISO currency code, in lowercase.
-
#customer ⇒ Object
readonly
The ID of the customer to bill for this invoice item.
-
#customer_account ⇒ Object
readonly
The ID of the account to bill for this invoice item.
-
#date ⇒ Object
readonly
Time at which the object was created.
-
#deleted ⇒ Object
readonly
Always true for a deleted object.
-
#description ⇒ Object
readonly
An arbitrary string attached to the object.
-
#discountable ⇒ Object
readonly
If true, discounts will apply to this invoice item.
-
#discounts ⇒ Object
readonly
The discounts which apply to the invoice item.
-
#frozen_fields ⇒ Object
readonly
Array of field names that can't be modified.
-
#id ⇒ Object
readonly
Unique identifier for the object.
-
#invoice ⇒ Object
readonly
The ID of the invoice this invoice item belongs to.
-
#livemode ⇒ Object
readonly
If the object exists in live mode, the value is
true. -
#managed_payments ⇒ Object
readonly
Attribute for field managed_payments.
-
#margins ⇒ Object
readonly
The margins which apply to the invoice item.
-
#metadata ⇒ Object
readonly
Set of key-value pairs that you can attach to an object.
-
#net_amount ⇒ Object
readonly
The amount after discounts, but before credits and taxes.
-
#object ⇒ Object
readonly
String representing the object's type.
-
#parent ⇒ Object
readonly
The parent that generated this invoice item.
-
#period ⇒ Object
readonly
Attribute for field period.
-
#pricing ⇒ Object
readonly
The pricing information of the invoice item.
-
#proration ⇒ Object
readonly
Whether the invoice item was created automatically as a proration adjustment when the customer switched plans.
-
#proration_details ⇒ Object
readonly
Attribute for field proration_details.
-
#quantity ⇒ Object
readonly
Quantity of units for the invoice item in integer format, with any decimal precision truncated.
-
#quantity_decimal ⇒ Object
readonly
Non-negative decimal with at most 12 decimal places.
-
#tax_rates ⇒ Object
readonly
The tax rates which apply to the invoice item.
-
#test_clock ⇒ Object
readonly
ID of the test clock this invoice item belongs to.
Attributes inherited from APIResource
Attributes inherited from StripeObject
Class Method Summary collapse
-
.create(params = {}, opts = {}) ⇒ Object
Creates an item to be added to a draft invoice (up to 250 items per invoice).
-
.delete(invoiceitem, params = {}, opts = {}) ⇒ Object
Deletes an invoice item, removing it from an invoice.
- .field_encodings ⇒ Object
- .field_remappings ⇒ Object
- .inner_class_types ⇒ Object
-
.list(params = {}, opts = {}) ⇒ Object
Returns a list of your invoice items.
- .object_name ⇒ Object
-
.update(invoiceitem, params = {}, opts = {}) ⇒ Object
Updates the amount or description of an invoice item on an upcoming invoice.
Instance Method Summary collapse
-
#delete(params = {}, opts = {}) ⇒ Object
Deletes an invoice item, removing it from an invoice.
Methods included from APIOperations::Create
Methods included from APIOperations::List
Methods included from APIOperations::Save
Methods included from APIOperations::Delete
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)
Amount (in the currency specified) of the invoice item. This should always be equal to unit_amount * quantity.
296 297 298 |
# File 'lib/stripe/resources/invoice_item.rb', line 296 def amount @amount end |
#currency ⇒ Object (readonly)
Three-letter ISO currency code, in lowercase. Must be a supported currency.
298 299 300 |
# File 'lib/stripe/resources/invoice_item.rb', line 298 def currency @currency end |
#customer ⇒ Object (readonly)
The ID of the customer to bill for this invoice item.
300 301 302 |
# File 'lib/stripe/resources/invoice_item.rb', line 300 def customer @customer end |
#customer_account ⇒ Object (readonly)
The ID of the account to bill for this invoice item.
302 303 304 |
# File 'lib/stripe/resources/invoice_item.rb', line 302 def customer_account @customer_account end |
#date ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
304 305 306 |
# File 'lib/stripe/resources/invoice_item.rb', line 304 def date @date end |
#deleted ⇒ Object (readonly)
Always true for a deleted object
306 307 308 |
# File 'lib/stripe/resources/invoice_item.rb', line 306 def deleted @deleted end |
#description ⇒ Object (readonly)
An arbitrary string attached to the object. Often useful for displaying to users.
308 309 310 |
# File 'lib/stripe/resources/invoice_item.rb', line 308 def description @description end |
#discountable ⇒ Object (readonly)
If true, discounts will apply to this invoice item. Always false for prorations.
310 311 312 |
# File 'lib/stripe/resources/invoice_item.rb', line 310 def discountable @discountable end |
#discounts ⇒ Object (readonly)
The discounts which apply to the invoice item. Item discounts are applied before invoice discounts. Use expand[]=discounts to expand each discount.
312 313 314 |
# File 'lib/stripe/resources/invoice_item.rb', line 312 def discounts @discounts end |
#frozen_fields ⇒ Object (readonly)
Array of field names that can't be modified. Attempting to update a frozen field returns an error.
314 315 316 |
# File 'lib/stripe/resources/invoice_item.rb', line 314 def frozen_fields @frozen_fields end |
#id ⇒ Object (readonly)
Unique identifier for the object.
316 317 318 |
# File 'lib/stripe/resources/invoice_item.rb', line 316 def id @id end |
#invoice ⇒ Object (readonly)
The ID of the invoice this invoice item belongs to.
318 319 320 |
# File 'lib/stripe/resources/invoice_item.rb', line 318 def invoice @invoice end |
#livemode ⇒ Object (readonly)
If the object exists in live mode, the value is true. If the object exists in test mode, the value is false.
320 321 322 |
# File 'lib/stripe/resources/invoice_item.rb', line 320 def livemode @livemode end |
#managed_payments ⇒ Object (readonly)
Attribute for field managed_payments
322 323 324 |
# File 'lib/stripe/resources/invoice_item.rb', line 322 def managed_payments @managed_payments end |
#margins ⇒ Object (readonly)
The margins which apply to the invoice item. When set, the default_margins on the invoice do not apply to this invoice item.
324 325 326 |
# File 'lib/stripe/resources/invoice_item.rb', line 324 def margins @margins end |
#metadata ⇒ Object (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.
326 327 328 |
# File 'lib/stripe/resources/invoice_item.rb', line 326 def @metadata end |
#net_amount ⇒ Object (readonly)
The amount after discounts, but before credits and taxes. This field is null for discountable=true items.
328 329 330 |
# File 'lib/stripe/resources/invoice_item.rb', line 328 def net_amount @net_amount end |
#object ⇒ Object (readonly)
String representing the object's type. Objects of the same type share the same value.
330 331 332 |
# File 'lib/stripe/resources/invoice_item.rb', line 330 def object @object end |
#parent ⇒ Object (readonly)
The parent that generated this invoice item.
332 333 334 |
# File 'lib/stripe/resources/invoice_item.rb', line 332 def parent @parent end |
#period ⇒ Object (readonly)
Attribute for field period
334 335 336 |
# File 'lib/stripe/resources/invoice_item.rb', line 334 def period @period end |
#pricing ⇒ Object (readonly)
The pricing information of the invoice item.
336 337 338 |
# File 'lib/stripe/resources/invoice_item.rb', line 336 def pricing @pricing end |
#proration ⇒ Object (readonly)
Whether the invoice item was created automatically as a proration adjustment when the customer switched plans.
338 339 340 |
# File 'lib/stripe/resources/invoice_item.rb', line 338 def proration @proration end |
#proration_details ⇒ Object (readonly)
Attribute for field proration_details
340 341 342 |
# File 'lib/stripe/resources/invoice_item.rb', line 340 def proration_details @proration_details end |
#quantity ⇒ Object (readonly)
Quantity of units for the invoice item in integer format, with any decimal precision truncated. For the 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 invoice item is a proration, the quantity of the subscription that the proration was computed for.
342 343 344 |
# File 'lib/stripe/resources/invoice_item.rb', line 342 def quantity @quantity end |
#quantity_decimal ⇒ Object (readonly)
Non-negative decimal with at most 12 decimal places. The quantity of units for the invoice item.
344 345 346 |
# File 'lib/stripe/resources/invoice_item.rb', line 344 def quantity_decimal @quantity_decimal end |
#tax_rates ⇒ Object (readonly)
The tax rates which apply to the invoice item. When set, the default_tax_rates on the invoice do not apply to this invoice item.
346 347 348 |
# File 'lib/stripe/resources/invoice_item.rb', line 346 def tax_rates @tax_rates end |
#test_clock ⇒ Object (readonly)
ID of the test clock this invoice item belongs to.
348 349 350 |
# File 'lib/stripe/resources/invoice_item.rb', line 348 def test_clock @test_clock end |
Class Method Details
.create(params = {}, opts = {}) ⇒ Object
Creates an item to be added to a draft invoice (up to 250 items per invoice). If no invoice is specified, the item will be on the next invoice created for the customer specified.
351 352 353 |
# File 'lib/stripe/resources/invoice_item.rb', line 351 def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/invoiceitems", params: params, opts: opts) end |
.delete(invoiceitem, params = {}, opts = {}) ⇒ Object
Deletes an invoice item, removing it from an invoice. Deleting invoice items is only possible when they're not attached to invoices, or if it's attached to a draft invoice.
356 357 358 359 360 361 362 363 |
# File 'lib/stripe/resources/invoice_item.rb', line 356 def self.delete(invoiceitem, params = {}, opts = {}) request_stripe_object( method: :delete, path: format("/v1/invoiceitems/%<invoiceitem>s", { invoiceitem: CGI.escape(invoiceitem) }), params: params, opts: opts ) end |
.field_encodings ⇒ Object
404 405 406 407 408 409 410 411 412 413 414 415 |
# File 'lib/stripe/resources/invoice_item.rb', line 404 def self.field_encodings @field_encodings = { pricing: { kind: :nullable, inner: { kind: :object, fields: { unit_amount_decimal: { kind: :nullable, inner: :decimal_string } }, }, }, quantity_decimal: :decimal_string, } end |
.field_remappings ⇒ Object
400 401 402 |
# File 'lib/stripe/resources/invoice_item.rb', line 400 def self.field_remappings @field_remappings = {} end |
.inner_class_types ⇒ Object
390 391 392 393 394 395 396 397 398 |
# File 'lib/stripe/resources/invoice_item.rb', line 390 def self.inner_class_types @inner_class_types = { managed_payments: ManagedPayments, parent: Parent, period: Period, pricing: Pricing, proration_details: ProrationDetails, } end |
.list(params = {}, opts = {}) ⇒ Object
Returns a list of your invoice items. Invoice items are returned sorted by creation date, with the most recently created invoice items appearing first.
376 377 378 |
# File 'lib/stripe/resources/invoice_item.rb', line 376 def self.list(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/invoiceitems", params: params, opts: opts) end |
.object_name ⇒ Object
20 21 22 |
# File 'lib/stripe/resources/invoice_item.rb', line 20 def self.object_name "invoiceitem" end |
.update(invoiceitem, params = {}, opts = {}) ⇒ Object
Updates the amount or description of an invoice item on an upcoming invoice. Updating an invoice item is only possible before the invoice it's attached to is closed.
381 382 383 384 385 386 387 388 |
# File 'lib/stripe/resources/invoice_item.rb', line 381 def self.update(invoiceitem, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/invoiceitems/%<invoiceitem>s", { invoiceitem: CGI.escape(invoiceitem) }), params: params, opts: opts ) end |
Instance Method Details
#delete(params = {}, opts = {}) ⇒ Object
Deletes an invoice item, removing it from an invoice. Deleting invoice items is only possible when they're not attached to invoices, or if it's attached to a draft invoice.
366 367 368 369 370 371 372 373 |
# File 'lib/stripe/resources/invoice_item.rb', line 366 def delete(params = {}, opts = {}) request_stripe_object( method: :delete, path: format("/v1/invoiceitems/%<invoiceitem>s", { invoiceitem: CGI.escape(self["id"]) }), params: params, opts: opts ) end |