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

A credit grant is an API resource that documents the allocation of some billing credits to a customer.

Related guide: Billing credits

Summary

Types

Amount of this credit grant.

Configuration specifying what this credit grant applies to. We currently only support metered prices that have a Billing Meter attached to them.

The monetary amount.

Specify the scope of this applicability config.

t()

The billing.credit_grant type.

Functions

Creates a credit grant.

Expires a credit grant.

Retrieve a list of credit grants.

Retrieves a credit grant.

Updates a credit grant.

Types

@type amount() :: %{optional(:monetary) => monetary(), optional(:type) => :monetary}

Amount of this credit grant.

Link to this type

applicability_config()

View Source
@type applicability_config() :: %{optional(:scope) => scope()}

Configuration specifying what this credit grant applies to. We currently only support metered prices that have a Billing Meter attached to them.

@type monetary() :: %{optional(:currency) => binary(), optional(:value) => integer()}

The monetary amount.

@type prices() :: %{optional(:id) => binary()}
@type scope() :: %{optional(:price_type) => :metered, optional(:prices) => [prices()]}

Specify the scope of this applicability config.

@type t() :: %Stripe.Billing.CreditGrant{
  amount: term(),
  applicability_config: term(),
  category: binary(),
  created: integer(),
  customer: binary() | Stripe.Customer.t() | Stripe.DeletedCustomer.t(),
  effective_at: integer() | nil,
  expires_at: integer() | nil,
  id: binary(),
  livemode: boolean(),
  metadata: term(),
  name: binary() | nil,
  object: binary(),
  priority: integer() | nil,
  test_clock: (binary() | Stripe.TestHelpers.TestClock.t()) | nil,
  updated: integer(),
  voided_at: integer() | nil
}

The billing.credit_grant type.

  • amount
  • applicability_config
  • category The category of this credit grant. This is for tracking purposes and isn't displayed to the customer.
  • created Time at which the object was created. Measured in seconds since the Unix epoch.
  • customer ID of the customer receiving the billing credits.
  • effective_at The time when the billing credits become effective-when they're eligible for use.
  • expires_at The time when the billing credits expire. If not present, the billing credits don't expire.
  • 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.
  • 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 A descriptive name shown in dashboard.
  • object String representing the object's type. Objects of the same type share the same value.
  • priority The priority for applying this credit grant. The highest priority is 0 and the lowest is 100.
  • test_clock ID of the test clock this credit grant belongs to.
  • updated Time at which the object was last updated. Measured in seconds since the Unix epoch.
  • voided_at The time when this credit grant was voided. If not present, the credit grant hasn't been voided.

Functions

Link to this function

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

View Source
@spec create(
  params :: %{
    optional(:amount) => amount(),
    optional(:applicability_config) => applicability_config(),
    optional(:category) => :paid | :promotional,
    optional(:customer) => binary(),
    optional(:effective_at) => integer(),
    optional(:expand) => [binary()],
    optional(:expires_at) => integer(),
    optional(:metadata) => %{optional(binary()) => binary()},
    optional(:name) => binary(),
    optional(:priority) => integer()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Creates a credit grant.

Details

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

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

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

Expires a credit grant.

Details

  • Method: post
  • Path: /v1/billing/credit_grants/{id}/expire
Link to this function

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

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

Retrieve a list of credit grants.

Details

  • Method: get
  • Path: /v1/billing/credit_grants
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 credit grant.

Details

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

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

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

Updates a credit grant.

Details

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

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

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

Voids a credit grant.

Details

  • Method: post
  • Path: /v1/billing/credit_grants/{id}/void