View Source Stripe.Sku (Striped v0.4.0)

Stores representations of stock keeping units. SKUs describe specific product variations, taking into account any combination of: attributes, currency, and cost. For example, a product may be a T-shirt, whereas a specific SKU represents the size: large, color: red version of that shirt.

Can also be used to manage inventory.

Link to this section Summary

Types

Description of the SKU's inventory.

t()

The sku type.

Functions

Creates a new SKU associated with a product.

Delete a SKU. Deleting a SKU is only possible until it has been used in an order.

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

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

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

Link to this section Types

@type inventory() :: %{
  optional(:quantity) => integer(),
  optional(:type) => :bucket | :finite | :infinite,
  optional(:value) => :in_stock | :limited | :out_of_stock
}

Description of the SKU's inventory.

@type package_dimensions() :: %{
  optional(:height) => number(),
  optional(:length) => number(),
  optional(:weight) => number(),
  optional(:width) => number()
}
@type t() :: %Stripe.Sku{
  active: boolean(),
  attributes: term(),
  created: integer(),
  currency: binary(),
  id: binary(),
  image: binary() | nil,
  inventory: term(),
  livemode: boolean(),
  metadata: term(),
  object: binary(),
  package_dimensions: term() | nil,
  price: integer(),
  product: binary() | Stripe.Product.t(),
  updated: integer()
}

The sku type.

  • active Whether the SKU is available for purchase.
  • attributes A dictionary of attributes and values for the attributes defined by the product. If, for example, a product's attributes are ["size", "gender"], a valid SKU has the following dictionary of attributes: {"size": "Medium", "gender": "Unisex"}.
  • created Time at which the object was created. Measured in seconds since the Unix epoch.
  • currency Three-letter ISO currency code, in lowercase. Must be a supported currency.
  • id Unique identifier for the object.
  • image The URL of an image for this SKU, meant to be displayable to the customer.
  • inventory
  • 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.
  • object String representing the object's type. Objects of the same type share the same value.
  • package_dimensions The dimensions of this SKU for shipping purposes.
  • price The cost of the item as a positive integer in the smallest currency unit (that is, 100 cents to charge $1.00, or 100 to charge ¥100, Japanese Yen being a zero-decimal currency).
  • product The ID of the product this SKU is associated with. The product must be currently active.
  • updated Time at which the object was last updated. Measured in seconds since the Unix epoch.

Link to this section Functions

Link to this function

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

View Source
@spec create(
  client :: Stripe.t(),
  params :: %{
    optional(:active) => boolean(),
    optional(:attributes) => map(),
    optional(:currency) => binary(),
    optional(:expand) => [binary()],
    optional(:id) => binary(),
    optional(:image) => binary(),
    optional(:inventory) => inventory(),
    optional(:metadata) => %{optional(binary()) => binary()},
    optional(:package_dimensions) => package_dimensions(),
    optional(:price) => integer(),
    optional(:product) => binary()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Creates a new SKU associated with a product.

Details

  • Method: post
  • Path: /v1/skus
Link to this function

delete(client, id, opts \\ [])

View Source
@spec delete(client :: Stripe.t(), id :: binary(), opts :: Keyword.t()) ::
  {:ok, Stripe.DeletedSku.t()}
  | {:error, Stripe.ApiErrors.t()}
  | {:error, term()}

Delete a SKU. Deleting a SKU is only possible until it has been used in an order.

Details

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

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

View Source
@spec list(
  client :: Stripe.t(),
  params :: %{
    optional(:active) => boolean(),
    optional(:attributes) => map(),
    optional(:ending_before) => binary(),
    optional(:expand) => [binary()],
    optional(:ids) => [binary()],
    optional(:in_stock) => boolean(),
    optional(:limit) => integer(),
    optional(:product) => binary(),
    optional(:starting_after) => binary()
  },
  opts :: Keyword.t()
) ::
  {:ok, Stripe.List.t(t())} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

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

Details

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

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

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

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

Details

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

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

View Source
@spec update(
  client :: Stripe.t(),
  id :: binary(),
  params :: %{
    optional(:active) => boolean(),
    optional(:attributes) => map(),
    optional(:currency) => binary(),
    optional(:expand) => [binary()],
    optional(:image) => binary(),
    optional(:inventory) => inventory(),
    optional(:metadata) => %{optional(binary()) => binary()} | binary(),
    optional(:package_dimensions) => package_dimensions() | binary(),
    optional(:price) => integer(),
    optional(:product) => binary()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

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

Note that a SKU’s attributes are not editable. Instead, you would need to deactivate the existing SKU and create a new one with the new attribute values.

Details

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