View Source ExOAPI.Stripe.SDK.SubscriptionItems (exoapi_stripe v0.1.4)

Link to this section Summary

Functions

description: <p>Deletes an item from the subscription. Removing a subscription item from a subscription will not cancel the subscription.</p>

description: <p>Returns a list of your subscription items for a given subscription.</p>

description: <p>Retrieves the subscription item with the given ID.</p>

description: <p>For the specified subscription item, returns a list of summary objects. Each object in the list provides usage information that’s been summarized from multiple usage records and over a subscription billing period (e.g., 15 usage records in the month of September).</p>

description: <p>Adds a new item to an existing subscription. No existing items will be changed or replaced.</p>

description: <p>Updates the plan or quantity of an item on a current subscription.</p>

description: <p>Creates a usage record for a specified subscription item and date, and fills it with a quantity.</p>

Link to this section Types

Link to this type

get_subscription_items_item_opts()

View Source
@type get_subscription_items_item_opts() :: {:expand, String.t()}
Link to this type

get_subscription_items_opts()

View Source
@type get_subscription_items_opts() ::
  {:starting_after, String.t()}
  | {:limit, String.t()}
  | {:expand, String.t()}
  | {:ending_before, String.t()}
Link to this type

get_subscription_items_subscription_item_usage_record_summaries_opts()

View Source
@type get_subscription_items_subscription_item_usage_record_summaries_opts() ::
  {:starting_after, String.t()}
  | {:limit, String.t()}
  | {:expand, String.t()}
  | {:ending_before, String.t()}

Link to this section Functions

Link to this function

delete_subscription_items_item(client, body, item)

View Source
@spec delete_subscription_items_item(
  client :: ExOAPI.Client.t(),
  body ::
    %{
      proration_date: integer(),
      proration_behavior:
        String.t() | :always_invoice | :create_prorations | :none,
      clear_usage: boolean()
    }
    | map(),
  item :: String.t()
) ::
  {:ok,
   ExOAPI.Stripe.Schemas.Error.t()
   | ExOAPI.Stripe.Schemas.DeletedSubscriptionItem.t()
   | map()}
  | {:error, any()}

description: <p>Deletes an item from the subscription. Removing a subscription item from a subscription will not cancel the subscription.</p>

Link to this function

get_subscription_items(client, subscription, opts \\ [])

View Source
@spec get_subscription_items(
  client :: ExOAPI.Client.t(),
  subscription :: String.t(),
  [get_subscription_items_opts()]
) ::
  {:ok,
   ExOAPI.Stripe.Schemas.Error.t()
   | %{
       url: String.t(),
       object: String.t() | :list,
       has_more: boolean(),
       data: [ExOAPI.Stripe.Schemas.SubscriptionItem.t()]
     }
   | map()}
  | {:error, any()}

description: <p>Returns a list of your subscription items for a given subscription.</p>

Link to this function

get_subscription_items_item(client, item, opts \\ [])

View Source
@spec get_subscription_items_item(
  client :: ExOAPI.Client.t(),
  item :: String.t(),
  [get_subscription_items_item_opts()]
) ::
  {:ok,
   ExOAPI.Stripe.Schemas.Error.t()
   | ExOAPI.Stripe.Schemas.SubscriptionItem.t()
   | map()}
  | {:error, any()}

description: <p>Retrieves the subscription item with the given ID.</p>

Link to this function

get_subscription_items_subscription_item_usage_record_summaries(client, subscription_item, opts \\ [])

View Source
@spec get_subscription_items_subscription_item_usage_record_summaries(
  client :: ExOAPI.Client.t(),
  subscription_item :: String.t(),
  [get_subscription_items_subscription_item_usage_record_summaries_opts()]
) ::
  {:ok,
   ExOAPI.Stripe.Schemas.Error.t()
   | %{
       url: String.t(),
       object: String.t() | :list,
       has_more: boolean(),
       data: [ExOAPI.Stripe.Schemas.UsageRecordSummary.t()]
     }
   | map()}
  | {:error, any()}

description: <p>For the specified subscription item, returns a list of summary objects. Each object in the list provides usage information that’s been summarized from multiple usage records and over a subscription billing period (e.g., 15 usage records in the month of September).</p>

The list is sorted in reverse-chronological order (newest first). The first list item represents the most current usage period that hasn’t ended yet. Since new usage records can still be added, the returned summary information for the subscription item’s ID should be seen as unstable until the subscription billing period ends.

Link to this function

post_subscription_items(client, body)

View Source
@spec post_subscription_items(
  client :: ExOAPI.Client.t(),
  body ::
    %{
      tax_rates: String.t() | [String.t()],
      subscription: String.t(),
      quantity: integer(),
      proration_date: integer(),
      proration_behavior:
        String.t() | :always_invoice | :create_prorations | :none,
      price_data: %{
        unit_amount_decimal: String.t(),
        unit_amount: integer(),
        tax_behavior: String.t() | :exclusive | :inclusive | :unspecified,
        recurring: %{
          interval_count: integer(),
          interval: String.t() | :day | :month | :week | :year
        },
        product: String.t(),
        currency: String.t()
      },
      price: String.t(),
      payment_behavior:
        String.t()
        | :allow_incomplete
        | :default_incomplete
        | :error_if_incomplete
        | :pending_if_incomplete,
      metadata: map(),
      expand: [String.t()],
      billing_thresholds: String.t() | %{usage_gte: integer()}
    }
    | map()
) ::
  {:ok,
   ExOAPI.Stripe.Schemas.Error.t()
   | ExOAPI.Stripe.Schemas.SubscriptionItem.t()
   | map()}
  | {:error, any()}

description: <p>Adds a new item to an existing subscription. No existing items will be changed or replaced.</p>

Link to this function

post_subscription_items_item(client, body, item)

View Source
@spec post_subscription_items_item(
  client :: ExOAPI.Client.t(),
  body ::
    %{
      tax_rates: String.t() | [String.t()],
      quantity: integer(),
      proration_date: integer(),
      proration_behavior:
        String.t() | :always_invoice | :create_prorations | :none,
      price_data: %{
        unit_amount_decimal: String.t(),
        unit_amount: integer(),
        tax_behavior: String.t() | :exclusive | :inclusive | :unspecified,
        recurring: %{
          interval_count: integer(),
          interval: String.t() | :day | :month | :week | :year
        },
        product: String.t(),
        currency: String.t()
      },
      price: String.t(),
      payment_behavior:
        String.t()
        | :allow_incomplete
        | :default_incomplete
        | :error_if_incomplete
        | :pending_if_incomplete,
      off_session: boolean(),
      metadata: String.t() | map(),
      expand: [String.t()],
      billing_thresholds: String.t() | %{usage_gte: integer()}
    }
    | map(),
  item :: String.t()
) ::
  {:ok,
   ExOAPI.Stripe.Schemas.Error.t()
   | ExOAPI.Stripe.Schemas.SubscriptionItem.t()
   | map()}
  | {:error, any()}

description: <p>Updates the plan or quantity of an item on a current subscription.</p>

Link to this function

post_subscription_items_subscription_item_usage_records(client, body, subscription_item)

View Source
@spec post_subscription_items_subscription_item_usage_records(
  client :: ExOAPI.Client.t(),
  body ::
    %{
      timestamp: integer() | String.t() | :now,
      quantity: integer(),
      expand: [String.t()],
      action: String.t() | :increment | :set
    }
    | map(),
  subscription_item :: String.t()
) ::
  {:ok,
   ExOAPI.Stripe.Schemas.Error.t()
   | ExOAPI.Stripe.Schemas.UsageRecord.t()
   | map()}
  | {:error, any()}

description: <p>Creates a usage record for a specified subscription item and date, and fills it with a quantity.</p>

Usage records provide quantity information that Stripe uses to track how much a customer is using your service. With usage information and the pricing model set up by the metered billing plan, Stripe helps you send accurate invoices to your customers.

The default calculation for usage is to add up all the quantity values of the usage records within a billing period. You can change this default behavior with the billing plan’s aggregate_usage parameter. When there is more than one usage record with the same timestamp, Stripe adds the quantity values together. In most cases, this is the desired resolution, however, you can change this behavior with the action parameter.

The default pricing model for metered billing is per-unit pricing. For finer granularity, you can configure metered billing to have a tiered pricing model.