View Source Stripe.Product (stripity_stripe v3.1.1)

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 to configure pricing in Payment Links, Checkout, and Subscriptions.

Related guides: Set up a subscription, share a Payment Link, accept payments with Checkout, and more about Products and Prices

Link to this section Summary

Types

Data used to generate a new Price object. This Price will be set as the default price for this product.

The dimensions of this product for shipping purposes.

The recurring components of a price such as interval and interval_count.

t()

The product type.

Functions

Creates a new product 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.

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

Retrieves the details of an existing product. Supply the unique product ID from either a product creation request or the product list, and Stripe will return the corresponding product information.

Search for products you’ve previously created using Stripe’s Search Query Language.Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up to an hour behind during outages. Search functionality is not available to merchants in India.

Updates the specific product by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

Link to this section Types

@type created() :: %{
  optional(:gt) => integer(),
  optional(:gte) => integer(),
  optional(:lt) => integer(),
  optional(:lte) => integer()
}
@type default_price_data() :: %{
  optional(:currency) => binary(),
  optional(:currency_options) => map(),
  optional(:recurring) => recurring(),
  optional(:tax_behavior) => :exclusive | :inclusive | :unspecified,
  optional(:unit_amount) => integer(),
  optional(:unit_amount_decimal) => binary()
}

Data used to generate a new Price object. This Price will be set as the default price for this product.

@type features() :: %{optional(:name) => binary()}
@type package_dimensions() :: %{
  optional(:height) => number(),
  optional(:length) => number(),
  optional(:weight) => number(),
  optional(:width) => number()
}

The dimensions of this product for shipping purposes.

@type recurring() :: %{
  optional(:interval) => :day | :month | :week | :year,
  optional(:interval_count) => integer()
}

The recurring components of a price such as interval and interval_count.

@type t() :: %Stripe.Product{
  active: boolean(),
  created: integer(),
  default_price: (binary() | Stripe.Price.t()) | nil,
  description: binary() | nil,
  features: term(),
  id: binary(),
  images: term(),
  livemode: boolean(),
  metadata: term(),
  name: binary(),
  object: binary(),
  package_dimensions: term() | nil,
  shippable: boolean() | nil,
  statement_descriptor: binary() | nil,
  tax_code: (binary() | Stripe.TaxCode.t()) | nil,
  type: binary(),
  unit_label: binary() | nil,
  updated: integer(),
  url: binary() | nil
}

The product type.

  • active Whether the product is currently available for purchase.
  • created Time at which the object was created. Measured in seconds since the Unix epoch.
  • default_price The ID of the Price object that is the default price for this product.
  • description 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.
  • features A list of up to 15 features for this product. These are displayed in pricing tables.
  • id Unique identifier for the object.
  • images A list of up to 8 URLs of images for this product, meant to be displayable to the customer.
  • livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode.
  • metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
  • name The product's name, meant to be displayable to the customer.
  • object String representing the object's type. Objects of the same type share the same value.
  • package_dimensions The dimensions of this product for shipping purposes.
  • shippable Whether this product is shipped (i.e., physical goods).
  • statement_descriptor 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.
  • tax_code A tax code ID.
  • type 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.
  • unit_label A label that represents units of this product. When set, this will be included in customers' receipts, invoices, Checkout, and the customer portal.
  • updated Time at which the object was last updated. Measured in seconds since the Unix epoch.
  • url A URL of a publicly-accessible webpage for this product.

Link to this section Functions

Link to this function

create(params \\ %{}, opts \\ [])

View Source
@spec create(
  params :: %{
    optional(:active) => boolean(),
    optional(:default_price_data) => default_price_data(),
    optional(:description) => binary(),
    optional(:expand) => [binary()],
    optional(:features) => [features()],
    optional(:id) => binary(),
    optional(:images) => [binary()],
    optional(:metadata) => %{optional(binary()) => binary()},
    optional(:name) => binary(),
    optional(:package_dimensions) => package_dimensions(),
    optional(:shippable) => boolean(),
    optional(:statement_descriptor) => binary(),
    optional(:tax_code) => binary(),
    optional(:type) => :good | :service,
    optional(:unit_label) => binary(),
    optional(:url) => binary()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Creates a new product object.

Details

  • Method: post
  • Path: /v1/products
@spec delete(id :: binary(), opts :: Keyword.t()) ::
  {:ok, Stripe.DeletedProduct.t()}
  | {:error, Stripe.ApiErrors.t()}
  | {:error, term()}

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.

Details

  • Method: delete
  • Path: /v1/products/{id}
Link to this function

list(params \\ %{}, opts \\ [])

View Source
@spec list(
  params :: %{
    optional(:active) => boolean(),
    optional(:created) => created() | integer(),
    optional(:ending_before) => binary(),
    optional(:expand) => [binary()],
    optional(:ids) => [binary()],
    optional(:limit) => integer(),
    optional(:shippable) => boolean(),
    optional(:starting_after) => binary(),
    optional(:type) => :good | :service,
    optional(:url) => binary()
  },
  opts :: Keyword.t()
) ::
  {:ok, Stripe.List.t(t())} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

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

Details

  • Method: get
  • Path: /v1/products
Link to this function

retrieve(id, params \\ %{}, opts \\ [])

View Source
@spec retrieve(
  id :: binary(),
  params :: %{optional(:expand) => [binary()]},
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Retrieves the details of an existing product. Supply the unique product ID from either a product creation request or the product list, and Stripe will return the corresponding product information.

Details

  • Method: get
  • Path: /v1/products/{id}
Link to this function

search(params \\ %{}, opts \\ [])

View Source
@spec search(
  params :: %{
    optional(:expand) => [binary()],
    optional(:limit) => integer(),
    optional(:page) => binary(),
    optional(:query) => binary()
  },
  opts :: Keyword.t()
) ::
  {:ok, Stripe.SearchResult.t(t())}
  | {:error, Stripe.ApiErrors.t()}
  | {:error, term()}

Search for products you’ve previously created using Stripe’s Search Query Language.Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up to an hour behind during outages. Search functionality is not available to merchants in India.

#### Details * Method: `get` * Path: `/v1/products/search`

Link to this function

update(id, params \\ %{}, opts \\ [])

View Source
@spec update(
  id :: binary(),
  params :: %{
    optional(:active) => boolean(),
    optional(:default_price) => binary(),
    optional(:description) => binary() | binary(),
    optional(:expand) => [binary()],
    optional(:features) => [features()] | binary(),
    optional(:images) => [binary()] | binary(),
    optional(:metadata) => %{optional(binary()) => binary()} | binary(),
    optional(:name) => binary(),
    optional(:package_dimensions) => package_dimensions() | binary(),
    optional(:shippable) => boolean(),
    optional(:statement_descriptor) => binary(),
    optional(:tax_code) => binary() | binary(),
    optional(:unit_label) => binary() | binary(),
    optional(:url) => binary() | binary()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Updates the specific product by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

Details

  • Method: post
  • Path: /v1/products/{id}