Class: Stripe::Product

Inherits:
APIResource show all
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](api.stripe.com#prices) to configure pricing in Payment Links, Checkout, and Subscriptions.

Related guides: [Set up a subscription](docs.stripe.com/billing/subscriptions/set-up-subscription), [share a Payment Link](docs.stripe.com/payment-links), [accept payments with Checkout](docs.stripe.com/payments/accept-a-payment#create-product-prices-upfront), and more about [Products and Prices](docs.stripe.com/products-prices/overview)

Defined Under Namespace

Classes: Identifiers, MarketingFeature, PackageDimensions, TaxDetails

Constant Summary collapse

OBJECT_NAME =
"product"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary collapse

Attributes inherited from APIResource

#save_with_parent

Attributes inherited from StripeObject

#last_response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::List

list

Methods included from APIOperations::NestedResource

nested_resource_class_methods

Methods included from APIOperations::Search

_search

Methods included from APIOperations::Save

included, #save

Methods included from APIOperations::Delete

included

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

included

Methods inherited from StripeObject

#==, #[], #[]=, #_get_inner_class_type, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, field_encodings, #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

#activeObject (readonly)

Whether the product is currently available for purchase.



100
101
102
# File 'lib/stripe/resources/product.rb', line 100

def active
  @active
end

#createdObject (readonly)

Time at which the object was created. Measured in seconds since the Unix epoch.



102
103
104
# File 'lib/stripe/resources/product.rb', line 102

def created
  @created
end

#default_priceObject (readonly)

The ID of the [Price](docs.stripe.com/api/prices) object that is the default price for this product.



104
105
106
# File 'lib/stripe/resources/product.rb', line 104

def default_price
  @default_price
end

#deletedObject (readonly)

Always true for a deleted object



106
107
108
# File 'lib/stripe/resources/product.rb', line 106

def deleted
  @deleted
end

#descriptionObject (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.



108
109
110
# File 'lib/stripe/resources/product.rb', line 108

def description
  @description
end

#idObject (readonly)

Unique identifier for the object.



110
111
112
# File 'lib/stripe/resources/product.rb', line 110

def id
  @id
end

#identifiersObject (readonly)

Attribute for field identifiers



112
113
114
# File 'lib/stripe/resources/product.rb', line 112

def identifiers
  @identifiers
end

#imagesObject (readonly)

A list of up to 8 URLs of images for this product, meant to be displayable to the customer.



114
115
116
# File 'lib/stripe/resources/product.rb', line 114

def images
  @images
end

#livemodeObject (readonly)

If the object exists in live mode, the value is ‘true`. If the object exists in test mode, the value is `false`.



116
117
118
# File 'lib/stripe/resources/product.rb', line 116

def livemode
  @livemode
end

#marketing_featuresObject (readonly)

A list of up to 15 marketing features for this product. These are displayed in [pricing tables](docs.stripe.com/payments/checkout/pricing-table).



118
119
120
# File 'lib/stripe/resources/product.rb', line 118

def marketing_features
  @marketing_features
end

#metadataObject (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.



120
121
122
# File 'lib/stripe/resources/product.rb', line 120

def 
  @metadata
end

#nameObject (readonly)

The product’s name, meant to be displayable to the customer.



122
123
124
# File 'lib/stripe/resources/product.rb', line 122

def name
  @name
end

#objectObject (readonly)

String representing the object’s type. Objects of the same type share the same value.



124
125
126
# File 'lib/stripe/resources/product.rb', line 124

def object
  @object
end

#package_dimensionsObject (readonly)

The dimensions of this product for shipping purposes.



126
127
128
# File 'lib/stripe/resources/product.rb', line 126

def package_dimensions
  @package_dimensions
end

#shippableObject (readonly)

Whether this product is shipped (i.e., physical goods).



128
129
130
# File 'lib/stripe/resources/product.rb', line 128

def shippable
  @shippable
end

#statement_descriptorObject (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.



130
131
132
# File 'lib/stripe/resources/product.rb', line 130

def statement_descriptor
  @statement_descriptor
end

#tax_codeObject (readonly)



132
133
134
# File 'lib/stripe/resources/product.rb', line 132

def tax_code
  @tax_code
end

#tax_detailsObject (readonly)

Tax details for this product, including the [tax code](/tax/tax-codes) and an optional performance location.



134
135
136
# File 'lib/stripe/resources/product.rb', line 134

def tax_details
  @tax_details
end

#typeObject (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.



136
137
138
# File 'lib/stripe/resources/product.rb', line 136

def type
  @type
end

#unit_labelObject (readonly)

A label that represents units of this product. When set, this will be included in customers’ receipts, invoices, Checkout, and the customer portal.



138
139
140
# File 'lib/stripe/resources/product.rb', line 138

def unit_label
  @unit_label
end

#updatedObject (readonly)

Time at which the object was last updated. Measured in seconds since the Unix epoch.



140
141
142
# File 'lib/stripe/resources/product.rb', line 140

def updated
  @updated
end

#urlObject (readonly)

A URL of a publicly-accessible webpage for this product.



142
143
144
# File 'lib/stripe/resources/product.rb', line 142

def url
  @url
end

Class Method Details

.create(params = {}, opts = {}) ⇒ Object

Creates a new product object.



145
146
147
# File 'lib/stripe/resources/product.rb', line 145

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.



150
151
152
153
154
155
156
157
# File 'lib/stripe/resources/product.rb', line 150

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

.field_remappingsObject



201
202
203
# File 'lib/stripe/resources/product.rb', line 201

def self.field_remappings
  @field_remappings = {}
end

.inner_class_typesObject



192
193
194
195
196
197
198
199
# File 'lib/stripe/resources/product.rb', line 192

def self.inner_class_types
  @inner_class_types = {
    identifiers: Identifiers,
    marketing_features: MarketingFeature,
    package_dimensions: PackageDimensions,
    tax_details: TaxDetails,
  }
end

.list(params = {}, opts = {}) ⇒ Object

Returns a list of your products. The products are returned sorted by creation date, with the most recently created products appearing first.



170
171
172
# File 'lib/stripe/resources/product.rb', line 170

def self.list(params = {}, opts = {})
  request_stripe_object(method: :get, path: "/v1/products", params: params, opts: opts)
end

.object_nameObject



22
23
24
# File 'lib/stripe/resources/product.rb', line 22

def self.object_name
  "product"
end

.search(params = {}, opts = {}) ⇒ Object



174
175
176
# File 'lib/stripe/resources/product.rb', line 174

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



178
179
180
# File 'lib/stripe/resources/product.rb', line 178

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.



183
184
185
186
187
188
189
190
# File 'lib/stripe/resources/product.rb', line 183

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.



160
161
162
163
164
165
166
167
# File 'lib/stripe/resources/product.rb', line 160

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