Class: Stripe::Product
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::Product
- Extended by:
- APIOperations::Create, APIOperations::List, APIOperations::NestedResource, APIOperations::Search
- Includes:
- APIOperations::Delete, APIOperations::Save
- Defined in:
- lib/stripe/resources/product.rb
Overview
Products describe the specific goods or services you offer to your customers. For example, you might offer a Standard and Premium version of your goods or service; each version would be a separate Product. They can be used in conjunction with [Prices](stripe.com/docs/api#prices) to configure pricing in Payment Links, Checkout, and Subscriptions.
Related guides: [Set up a subscription](stripe.com/docs/billing/subscriptions/set-up-subscription), [share a Payment Link](stripe.com/docs/payment-links), [accept payments with Checkout](stripe.com/docs/payments/accept-a-payment#create-product-prices-upfront), and more about [Products and Prices](stripe.com/docs/products-prices/overview)
Defined Under Namespace
Classes: MarketingFeature, PackageDimensions, Provisioning
Constant Summary collapse
- OBJECT_NAME =
"product"
Constants inherited from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
Whether the product is currently available for purchase.
-
#created ⇒ Object
readonly
Time at which the object was created.
-
#default_price ⇒ Object
readonly
The ID of the [Price](stripe.com/docs/api/prices) object that is the default price for this product.
-
#deleted ⇒ Object
readonly
Always true for a deleted object.
-
#description ⇒ Object
readonly
The product’s description, meant to be displayable to the customer.
-
#id ⇒ Object
readonly
Unique identifier for the object.
-
#images ⇒ Object
readonly
A list of up to 8 URLs of images for this product, meant to be displayable to the customer.
-
#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.
-
#marketing_features ⇒ Object
readonly
A list of up to 15 marketing features for this product.
-
#metadata ⇒ Object
readonly
Set of [key-value pairs](stripe.com/docs/api/metadata) that you can attach to an object.
-
#name ⇒ Object
readonly
The product’s name, meant to be displayable to the customer.
-
#object ⇒ Object
readonly
String representing the object’s type.
-
#package_dimensions ⇒ Object
readonly
The dimensions of this product for shipping purposes.
-
#provisioning ⇒ Object
readonly
Provisioning configuration for this product.
-
#shippable ⇒ Object
readonly
Whether this product is shipped (i.e., physical goods).
-
#statement_descriptor ⇒ Object
readonly
Extra information about a product which will appear on your customer’s credit card statement.
-
#tax_code ⇒ Object
readonly
A [tax code](stripe.com/docs/tax/tax-categories) ID.
-
#type ⇒ Object
readonly
The type of the product.
-
#unit_label ⇒ Object
readonly
A label that represents units of this product.
-
#updated ⇒ Object
readonly
Time at which the object was last updated.
-
#url ⇒ Object
readonly
A URL of a publicly-accessible webpage for this product.
Attributes inherited from APIResource
Attributes inherited from StripeObject
Class Method Summary collapse
-
.create(params = {}, opts = {}) ⇒ Object
Creates a new product object.
-
.delete(id, params = {}, opts = {}) ⇒ Object
Delete a product.
-
.list(filters = {}, opts = {}) ⇒ Object
Returns a list of your products.
- .object_name ⇒ Object
- .search(params = {}, opts = {}) ⇒ Object
- .search_auto_paging_each(params = {}, opts = {}, &blk) ⇒ Object
-
.update(id, params = {}, opts = {}) ⇒ Object
Updates the specific product by setting the values of the parameters passed.
Instance Method Summary collapse
-
#delete(params = {}, opts = {}) ⇒ Object
Delete a product.
Methods included from APIOperations::Create
Methods included from APIOperations::List
Methods included from APIOperations::NestedResource
Methods included from APIOperations::Search
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
#active ⇒ Object (readonly)
Whether the product is currently available for purchase.
46 47 48 |
# File 'lib/stripe/resources/product.rb', line 46 def active @active end |
#created ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
48 49 50 |
# File 'lib/stripe/resources/product.rb', line 48 def created @created end |
#default_price ⇒ Object (readonly)
The ID of the [Price](stripe.com/docs/api/prices) object that is the default price for this product.
50 51 52 |
# File 'lib/stripe/resources/product.rb', line 50 def default_price @default_price end |
#deleted ⇒ Object (readonly)
Always true for a deleted object
86 87 88 |
# File 'lib/stripe/resources/product.rb', line 86 def deleted @deleted end |
#description ⇒ Object (readonly)
The product’s description, meant to be displayable to the customer. Use this field to optionally store a long form explanation of the product being sold for your own rendering purposes.
52 53 54 |
# File 'lib/stripe/resources/product.rb', line 52 def description @description end |
#id ⇒ Object (readonly)
Unique identifier for the object.
54 55 56 |
# File 'lib/stripe/resources/product.rb', line 54 def id @id end |
#images ⇒ Object (readonly)
A list of up to 8 URLs of images for this product, meant to be displayable to the customer.
56 57 58 |
# File 'lib/stripe/resources/product.rb', line 56 def images @images 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.
58 59 60 |
# File 'lib/stripe/resources/product.rb', line 58 def livemode @livemode end |
#marketing_features ⇒ Object (readonly)
A list of up to 15 marketing features for this product. These are displayed in [pricing tables](stripe.com/docs/payments/checkout/pricing-table).
60 61 62 |
# File 'lib/stripe/resources/product.rb', line 60 def marketing_features @marketing_features 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.
62 63 64 |
# File 'lib/stripe/resources/product.rb', line 62 def @metadata end |
#name ⇒ Object (readonly)
The product’s name, meant to be displayable to the customer.
64 65 66 |
# File 'lib/stripe/resources/product.rb', line 64 def name @name end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
66 67 68 |
# File 'lib/stripe/resources/product.rb', line 66 def object @object end |
#package_dimensions ⇒ Object (readonly)
The dimensions of this product for shipping purposes.
68 69 70 |
# File 'lib/stripe/resources/product.rb', line 68 def package_dimensions @package_dimensions end |
#provisioning ⇒ Object (readonly)
Provisioning configuration for this product.
70 71 72 |
# File 'lib/stripe/resources/product.rb', line 70 def provisioning @provisioning end |
#shippable ⇒ Object (readonly)
Whether this product is shipped (i.e., physical goods).
72 73 74 |
# File 'lib/stripe/resources/product.rb', line 72 def shippable @shippable end |
#statement_descriptor ⇒ Object (readonly)
Extra information about a product which will appear on your customer’s credit card statement. In the case that multiple products are billed at once, the first statement descriptor will be used. Only used for subscription payments.
74 75 76 |
# File 'lib/stripe/resources/product.rb', line 74 def statement_descriptor @statement_descriptor end |
#tax_code ⇒ Object (readonly)
A [tax code](stripe.com/docs/tax/tax-categories) ID.
76 77 78 |
# File 'lib/stripe/resources/product.rb', line 76 def tax_code @tax_code end |
#type ⇒ Object (readonly)
The type of the product. The product is either of type ‘good`, which is eligible for use with Orders and SKUs, or `service`, which is eligible for use with Subscriptions and Plans.
78 79 80 |
# File 'lib/stripe/resources/product.rb', line 78 def type @type end |
#unit_label ⇒ Object (readonly)
A label that represents units of this product. When set, this will be included in customers’ receipts, invoices, Checkout, and the customer portal.
80 81 82 |
# File 'lib/stripe/resources/product.rb', line 80 def unit_label @unit_label end |
#updated ⇒ Object (readonly)
Time at which the object was last updated. Measured in seconds since the Unix epoch.
82 83 84 |
# File 'lib/stripe/resources/product.rb', line 82 def updated @updated end |
#url ⇒ Object (readonly)
A URL of a publicly-accessible webpage for this product.
84 85 86 |
# File 'lib/stripe/resources/product.rb', line 84 def url @url end |
Class Method Details
.create(params = {}, opts = {}) ⇒ Object
Creates a new product object.
89 90 91 |
# File 'lib/stripe/resources/product.rb', line 89 def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/products", params: params, opts: opts) end |
.delete(id, params = {}, opts = {}) ⇒ Object
Delete a product. Deleting a product is only possible if it has no prices associated with it. Additionally, deleting a product with type=good is only possible if it has no SKUs associated with it.
94 95 96 97 98 99 100 101 |
# File 'lib/stripe/resources/product.rb', line 94 def self.delete(id, params = {}, opts = {}) request_stripe_object( method: :delete, path: format("/v1/products/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts ) end |
.list(filters = {}, opts = {}) ⇒ Object
Returns a list of your products. The products are returned sorted by creation date, with the most recently created products appearing first.
114 115 116 |
# File 'lib/stripe/resources/product.rb', line 114 def self.list(filters = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/products", params: filters, opts: opts) end |
.object_name ⇒ Object
22 23 24 |
# File 'lib/stripe/resources/product.rb', line 22 def self.object_name "product" end |
.search(params = {}, opts = {}) ⇒ Object
118 119 120 |
# File 'lib/stripe/resources/product.rb', line 118 def self.search(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/products/search", params: params, opts: opts) end |
.search_auto_paging_each(params = {}, opts = {}, &blk) ⇒ Object
122 123 124 |
# File 'lib/stripe/resources/product.rb', line 122 def self.search_auto_paging_each(params = {}, opts = {}, &blk) search(params, opts).auto_paging_each(&blk) end |
.update(id, params = {}, opts = {}) ⇒ Object
Updates the specific product by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
127 128 129 130 131 132 133 134 |
# File 'lib/stripe/resources/product.rb', line 127 def self.update(id, params = {}, opts = {}) request_stripe_object( method: :post, path: format("/v1/products/%<id>s", { id: CGI.escape(id) }), params: params, opts: opts ) end |
Instance Method Details
#delete(params = {}, opts = {}) ⇒ Object
Delete a product. Deleting a product is only possible if it has no prices associated with it. Additionally, deleting a product with type=good is only possible if it has no SKUs associated with it.
104 105 106 107 108 109 110 111 |
# File 'lib/stripe/resources/product.rb', line 104 def delete(params = {}, opts = {}) request_stripe_object( method: :delete, path: format("/v1/products/%<id>s", { id: CGI.escape(self["id"]) }), params: params, opts: opts ) end |