Stripe.TestHelpers.TestClock (stripity_stripe v3.3.2)

View Source

A test clock enables deterministic control over objects in testmode. With a test clock, you can create objects at a frozen time in the past or future, and advance to a specific future time to observe webhooks and state changes. After the clock advances, you can either validate the current state of your scenario (and test your assumptions), change the current state of your scenario (and test more complex scenarios), or keep advancing forward in time.

Summary

Types

t()

The test_helpers.test_clock type.

Functions

Starts advancing a test clock to a specified time in the future. Advancement is done when status changes to Ready.

Creates a new test clock that can be attached to new customers and quotes.

Deletes a test clock.

Returns a list of your test clocks.

Types

t()

@type t() :: %Stripe.TestHelpers.TestClock{
  created: integer(),
  deletes_after: integer(),
  frozen_time: integer(),
  id: binary(),
  livemode: boolean(),
  name: binary() | nil,
  object: binary(),
  status: binary(),
  status_details: term()
}

The test_helpers.test_clock type.

  • created Time at which the object was created. Measured in seconds since the Unix epoch.
  • deletes_after Time at which this clock is scheduled to auto delete.
  • frozen_time Time at which all objects belonging to this clock are frozen.
  • 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.
  • name The custom name supplied at creation.
  • object String representing the object's type. Objects of the same type share the same value.
  • status The status of the Test Clock.
  • status_details

Functions

advance(test_clock, params \\ %{}, opts \\ [])

@spec advance(
  test_clock :: binary(),
  params :: %{
    optional(:expand) => [binary()],
    optional(:frozen_time) => integer()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Starts advancing a test clock to a specified time in the future. Advancement is done when status changes to Ready.

Details

  • Method: post
  • Path: /v1/test_helpers/test_clocks/{test_clock}/advance

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

@spec create(
  params :: %{
    optional(:expand) => [binary()],
    optional(:frozen_time) => integer(),
    optional(:name) => binary()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Creates a new test clock that can be attached to new customers and quotes.

Details

  • Method: post
  • Path: /v1/test_helpers/test_clocks

delete(test_clock, opts \\ [])

@spec delete(test_clock :: binary(), opts :: Keyword.t()) ::
  {:ok, Stripe.DeletedTestHelpers.TestClock.t()}
  | {:error, Stripe.ApiErrors.t()}
  | {:error, term()}

Deletes a test clock.

Details

  • Method: delete
  • Path: /v1/test_helpers/test_clocks/{test_clock}

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

@spec list(
  params :: %{
    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()}

Returns a list of your test clocks.

Details

  • Method: get
  • Path: /v1/test_helpers/test_clocks

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

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

Retrieves a test clock.

Details

  • Method: get
  • Path: /v1/test_helpers/test_clocks/{test_clock}