View Source Stripe.Billing.Meter (stripity_stripe v3.3.1)

Meters specify how to aggregate meter events over a billing period. Meter events represent the actions that customers take in your system. Meters attach to prices and form the basis of the bill.

Related guide: Usage based billing

Summary

Types

Fields that specify how to map a meter event to a customer.

The default settings to aggregate a meter's events with.

t()

The billing.meter type.

Fields that specify how to calculate a meter event's value.

Functions

Creates a billing meter.

When a meter is deactivated, no more meter events will be accepted for this meter. You can’t attach a deactivated meter to a price.

Retrieve a list of billing meters.

When a meter is reactivated, events for this meter can be accepted and you can attach the meter to a price.

Retrieves a billing meter given an ID.

Updates a billing meter.

Types

@type customer_mapping() :: %{
  optional(:event_payload_key) => binary(),
  optional(:type) => :by_id
}

Fields that specify how to map a meter event to a customer.

@type default_aggregation() :: %{optional(:formula) => :count | :last | :sum}

The default settings to aggregate a meter's events with.

@type t() :: %Stripe.Billing.Meter{
  created: integer(),
  customer_mapping: term(),
  default_aggregation: term(),
  display_name: binary(),
  event_name: binary(),
  event_time_window: binary() | nil,
  id: binary(),
  livemode: boolean(),
  object: binary(),
  status: binary(),
  status_transitions: term(),
  updated: integer(),
  value_settings: term()
}

The billing.meter type.

  • created Time at which the object was created. Measured in seconds since the Unix epoch.
  • customer_mapping
  • default_aggregation
  • display_name The meter's name.
  • event_name The name of the meter event to record usage for. Corresponds with the event_name field on meter events.
  • event_time_window The time window which meter events have been pre-aggregated for, if any.
  • id Unique identifier for the object.
  • livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode.
  • object String representing the object's type. Objects of the same type share the same value.
  • status The meter's status.
  • status_transitions
  • updated Time at which the object was last updated. Measured in seconds since the Unix epoch.
  • value_settings
@type value_settings() :: %{optional(:event_payload_key) => binary()}

Fields that specify how to calculate a meter event's value.

Functions

Link to this function

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

View Source
@spec create(
  params :: %{
    optional(:customer_mapping) => customer_mapping(),
    optional(:default_aggregation) => default_aggregation(),
    optional(:display_name) => binary(),
    optional(:event_name) => binary(),
    optional(:event_time_window) => :day | :hour,
    optional(:expand) => [binary()],
    optional(:value_settings) => value_settings()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Creates a billing meter.

Details

  • Method: post
  • Path: /v1/billing/meters
Link to this function

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

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

When a meter is deactivated, no more meter events will be accepted for this meter. You can’t attach a deactivated meter to a price.

Details

  • Method: post
  • Path: /v1/billing/meters/{id}/deactivate
Link to this function

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

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

Retrieve a list of billing meters.

Details

  • Method: get
  • Path: /v1/billing/meters
Link to this function

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

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

When a meter is reactivated, events for this meter can be accepted and you can attach the meter to a price.

Details

  • Method: post
  • Path: /v1/billing/meters/{id}/reactivate
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 a billing meter given an ID.

Details

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

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

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

Updates a billing meter.

Details

  • Method: post
  • Path: /v1/billing/meters/{id}