Class: Stripe::SubscriptionItem
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::SubscriptionItem
- Extended by:
- APIOperations::Create, APIOperations::List
- Includes:
- APIOperations::Delete, APIOperations::Save
- Defined in:
- lib/stripe/resources/subscription_item.rb
Overview
Subscription items allow you to create customer subscriptions with more than one plan, making it easy to represent complex billing relationships.
Defined Under Namespace
Classes: BillingThresholds, CreateParams, DeleteParams, ListParams, UpdateParams
Constant Summary collapse
- OBJECT_NAME =
"subscription_item"
Constants inherited from StripeObject
Stripe::StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary collapse
-
#billing_thresholds ⇒ Object
readonly
Define thresholds at which an invoice will be sent, and the related subscription advanced to a new billing period.
-
#created ⇒ Object
readonly
Time at which the object was created.
-
#current_period_end ⇒ Object
readonly
The end time of this subscription item’s current billing period.
-
#current_period_start ⇒ Object
readonly
The start time of this subscription item’s current billing period.
-
#deleted ⇒ Object
readonly
Always true for a deleted object.
-
#discounts ⇒ Object
readonly
The discounts applied to the subscription item.
-
#id ⇒ Object
readonly
Unique identifier for the object.
-
#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.
-
#plan ⇒ Object
readonly
You can now model subscriptions more flexibly using the [Prices API](stripe.com/docs/api#prices).
-
#price ⇒ Object
readonly
Prices define the unit cost, currency, and (optional) billing cycle for both recurring and one-time purchases of products.
-
#quantity ⇒ Object
readonly
The [quantity](stripe.com/docs/subscriptions/quantities) of the plan to which the customer should be subscribed.
-
#subscription ⇒ Object
readonly
The ‘subscription` this `subscription_item` belongs to.
-
#tax_rates ⇒ Object
readonly
The tax rates which apply to this ‘subscription_item`.
Attributes inherited from APIResource
Attributes inherited from StripeObject
Class Method Summary collapse
-
.create(params = {}, opts = {}) ⇒ Object
Adds a new item to an existing subscription.
-
.delete(item, params = {}, opts = {}) ⇒ Object
Deletes an item from the subscription.
-
.list(params = {}, opts = {}) ⇒ Object
Returns a list of your subscription items for a given subscription.
- .object_name ⇒ Object
-
.update(item, params = {}, opts = {}) ⇒ Object
Updates the plan or quantity of an item on a current subscription.
Instance Method Summary collapse
-
#delete(params = {}, opts = {}) ⇒ Object
Deletes an item from the subscription.
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
#==, #[], #[]=, 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
#billing_thresholds ⇒ Object (readonly)
Define thresholds at which an invoice will be sent, and the related subscription advanced to a new billing period
325 326 327 |
# File 'lib/stripe/resources/subscription_item.rb', line 325 def billing_thresholds @billing_thresholds end |
#created ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
327 328 329 |
# File 'lib/stripe/resources/subscription_item.rb', line 327 def created @created end |
#current_period_end ⇒ Object (readonly)
The end time of this subscription item’s current billing period.
329 330 331 |
# File 'lib/stripe/resources/subscription_item.rb', line 329 def current_period_end @current_period_end end |
#current_period_start ⇒ Object (readonly)
The start time of this subscription item’s current billing period.
331 332 333 |
# File 'lib/stripe/resources/subscription_item.rb', line 331 def current_period_start @current_period_start end |
#deleted ⇒ Object (readonly)
Always true for a deleted object
363 364 365 |
# File 'lib/stripe/resources/subscription_item.rb', line 363 def deleted @deleted end |
#discounts ⇒ Object (readonly)
The discounts applied to the subscription item. Subscription item discounts are applied before subscription discounts. Use ‘expand[]=discounts` to expand each discount.
333 334 335 |
# File 'lib/stripe/resources/subscription_item.rb', line 333 def discounts @discounts end |
#id ⇒ Object (readonly)
Unique identifier for the object.
335 336 337 |
# File 'lib/stripe/resources/subscription_item.rb', line 335 def id @id 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.
337 338 339 |
# File 'lib/stripe/resources/subscription_item.rb', line 337 def @metadata end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
339 340 341 |
# File 'lib/stripe/resources/subscription_item.rb', line 339 def object @object end |
#plan ⇒ Object (readonly)
You can now model subscriptions more flexibly using the [Prices API](stripe.com/docs/api#prices). It replaces the Plans API and is backwards compatible to simplify your migration.
Plans define the base price, currency, and billing cycle for recurring purchases of products. [Products](stripe.com/docs/api#products) help you track inventory or provisioning, and plans help you track pricing. Different physical goods or levels of service should be represented by products, and pricing options should be represented by plans. This approach lets you change prices without having to change your provisioning scheme.
For example, you might have a single “gold” product that has plans for $10/month, $100/year, €9/month, and €90/year.
Related guides: [Set up a subscription](stripe.com/docs/billing/subscriptions/set-up-subscription) and more about [products and prices](stripe.com/docs/products-prices/overview).
348 349 350 |
# File 'lib/stripe/resources/subscription_item.rb', line 348 def plan @plan end |
#price ⇒ Object (readonly)
Prices define the unit cost, currency, and (optional) billing cycle for both recurring and one-time purchases of products. [Products](stripe.com/docs/api#products) help you track inventory or provisioning, and prices help you track payment terms. Different physical goods or levels of service should be represented by products, and pricing options should be represented by prices. This approach lets you change prices without having to change your provisioning scheme.
For example, you might have a single “gold” product that has prices for $10/month, $100/year, and €9 once.
Related guides: [Set up a subscription](stripe.com/docs/billing/subscriptions/set-up-subscription), [create an invoice](stripe.com/docs/billing/invoices/create), and more about [products and prices](stripe.com/docs/products-prices/overview).
355 356 357 |
# File 'lib/stripe/resources/subscription_item.rb', line 355 def price @price end |
#quantity ⇒ Object (readonly)
The [quantity](stripe.com/docs/subscriptions/quantities) of the plan to which the customer should be subscribed.
357 358 359 |
# File 'lib/stripe/resources/subscription_item.rb', line 357 def quantity @quantity end |
#subscription ⇒ Object (readonly)
The ‘subscription` this `subscription_item` belongs to.
359 360 361 |
# File 'lib/stripe/resources/subscription_item.rb', line 359 def subscription @subscription end |
#tax_rates ⇒ Object (readonly)
The tax rates which apply to this ‘subscription_item`. When set, the `default_tax_rates` on the subscription do not apply to this `subscription_item`.
361 362 363 |
# File 'lib/stripe/resources/subscription_item.rb', line 361 def tax_rates @tax_rates end |
Class Method Details
.create(params = {}, opts = {}) ⇒ Object
Adds a new item to an existing subscription. No existing items will be changed or replaced.
366 367 368 369 370 371 372 373 |
# File 'lib/stripe/resources/subscription_item.rb', line 366 def self.create(params = {}, opts = {}) request_stripe_object( method: :post, path: "/v1/subscription_items", params: params, opts: opts ) end |
.delete(item, params = {}, opts = {}) ⇒ Object
Deletes an item from the subscription. Removing a subscription item from a subscription will not cancel the subscription.
376 377 378 379 380 381 382 383 |
# File 'lib/stripe/resources/subscription_item.rb', line 376 def self.delete(item, params = {}, opts = {}) request_stripe_object( method: :delete, path: format("/v1/subscription_items/%<item>s", { item: CGI.escape(item) }), params: params, opts: opts ) end |
.list(params = {}, opts = {}) ⇒ Object
Returns a list of your subscription items for a given subscription.
396 397 398 399 400 401 402 403 |
# File 'lib/stripe/resources/subscription_item.rb', line 396 def self.list(params = {}, opts = {}) request_stripe_object( method: :get, path: "/v1/subscription_items", params: params, opts: opts ) end |
.object_name ⇒ Object
14 15 16 |
# File 'lib/stripe/resources/subscription_item.rb', line 14 def self.object_name "subscription_item" end |
.update(item, params = {}, opts = {}) ⇒ Object
Updates the plan or quantity of an item on a current subscription.
406 407 408 409 410 411 412 413 |
# File 'lib/stripe/resources/subscription_item.rb', line 406 def self.update(item, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/subscription_items/%<item>s", { item: CGI.escape(item) }), params: params, opts: opts ) end |
Instance Method Details
#delete(params = {}, opts = {}) ⇒ Object
Deletes an item from the subscription. Removing a subscription item from a subscription will not cancel the subscription.
386 387 388 389 390 391 392 393 |
# File 'lib/stripe/resources/subscription_item.rb', line 386 def delete(params = {}, opts = {}) request_stripe_object( method: :delete, path: format("/v1/subscription_items/%<item>s", { item: CGI.escape(self["id"]) }), params: params, opts: opts ) end |