Class: Stripe::Product
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::Product
- Extended by:
- APIOperations::Create, APIOperations::List, 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)
Constant Summary collapse
- OBJECT_NAME =
"product"
Constants inherited from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary
Attributes inherited from APIResource
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::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
Class Method Details
.create(params = {}, opts = {}) ⇒ Object
Creates a new product object.
26 27 28 |
# File 'lib/stripe/resources/product.rb', line 26 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.
31 32 33 34 35 36 37 38 |
# File 'lib/stripe/resources/product.rb', line 31 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.
51 52 53 |
# File 'lib/stripe/resources/product.rb', line 51 def self.list(filters = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/products", params: filters, opts: opts) end |
.object_name ⇒ Object
21 22 23 |
# File 'lib/stripe/resources/product.rb', line 21 def self.object_name "product" end |
.search(params = {}, opts = {}) ⇒ Object
55 56 57 |
# File 'lib/stripe/resources/product.rb', line 55 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
59 60 61 |
# File 'lib/stripe/resources/product.rb', line 59 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.
64 65 66 67 68 69 70 71 |
# File 'lib/stripe/resources/product.rb', line 64 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.
41 42 43 44 45 46 47 48 |
# File 'lib/stripe/resources/product.rb', line 41 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 |