Class: Stripe::OrderService::CreateParams::LineItem

Inherits:
RequestParams
  • Object
show all
Defined in:
lib/stripe/services/order_service.rb

Defined Under Namespace

Classes: Discount, PriceData, ProductData

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from RequestParams

#to_h

Constructor Details

#initialize(description: nil, discounts: nil, price: nil, price_data: nil, product: nil, product_data: nil, quantity: nil, tax_rates: nil) ⇒ LineItem

Returns a new instance of LineItem.



295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/stripe/services/order_service.rb', line 295

def initialize(
  description: nil,
  discounts: nil,
  price: nil,
  price_data: nil,
  product: nil,
  product_data: nil,
  quantity: nil,
  tax_rates: nil
)
  @description = description
  @discounts = discounts
  @price = price
  @price_data = price_data
  @product = product
  @product_data = product_data
  @quantity = quantity
  @tax_rates = tax_rates
end

Instance Attribute Details

#descriptionObject

The description for the line item. Will default to the name of the associated product.



260
261
262
# File 'lib/stripe/services/order_service.rb', line 260

def description
  @description
end

#discountsObject

The discounts applied to this line item.



263
264
265
# File 'lib/stripe/services/order_service.rb', line 263

def discounts
  @discounts
end

#priceObject

The ID of a [Price](stripe.com/docs/api/prices) to add to the Order.

The ‘price` parameter is an alternative to using the `product` parameter. If each of your products are sold at a single price, you can set `Product.default_price` and then pass the `product` parameter when creating a line item. If your products are sold at several possible prices, use the `price` parameter to explicitly specify which one to use.



268
269
270
# File 'lib/stripe/services/order_service.rb', line 268

def price
  @price
end

#price_dataObject

Data used to generate a new Price object inline.

The ‘price_data` parameter is an alternative to using the `product` or `price` parameters. If you create products upfront and configure a `Product.default_price`, pass the `product` parameter when creating a line item. If you prefer not to define products upfront, or if you charge variable prices, pass the `price_data` parameter to describe the price for this line item.

Each time you pass ‘price_data` we create a Price for the product. This Price is hidden in both the Dashboard and API lists and cannot be reused.



275
276
277
# File 'lib/stripe/services/order_service.rb', line 275

def price_data
  @price_data
end

#productObject

The ID of a [Product](stripe.com/docs/api/products) to add to the Order.

The product must have a ‘default_price` specified. Otherwise, specify the price by passing the `price` or `price_data` parameter.



280
281
282
# File 'lib/stripe/services/order_service.rb', line 280

def product
  @product
end

#product_dataObject

Defines a Product inline and adds it to the Order.

‘product_data` is an alternative to the `product` parameter. If you created a Product upfront, use the `product` parameter to refer to the existing Product. But if you prefer not to create Products upfront, pass the `product_data` parameter to define a Product inline as part of configuring the Order.

‘product_data` automatically creates a Product, just as if you had manually created the Product. If a Product with the same ID already exists, then `product_data` re-uses it to avoid duplicates.



287
288
289
# File 'lib/stripe/services/order_service.rb', line 287

def product_data
  @product_data
end

#quantityObject

The quantity of the line item.



290
291
292
# File 'lib/stripe/services/order_service.rb', line 290

def quantity
  @quantity
end

#tax_ratesObject

The tax rates applied to this line item.



293
294
295
# File 'lib/stripe/services/order_service.rb', line 293

def tax_rates
  @tax_rates
end