Create a test clock Test helper

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

Parameters

  • frozen_timetimestampRequired

    The initial frozen time for this test clock.

  • namestring

    The name for this test clock.

Returns

The newly created TestClock object is returned upon success. Otherwise, this call throws an error.

POST /v1/test_helpers/test_clocks
// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://dashboard.stripe.com/apikeys
$stripe = new \Stripe\StripeClient('sk_test_BQokikJ...2HlWgH4olfQ2sk_test_BQokikJOvBiI2HlWgH4olfQ2');
$testClock = $stripe->testHelpers->testClocks->create(['frozen_time' => 1577836800]);
Response
{
"id": "clock_1Mr3I22eZvKYlo2Ck0rgMqd7",
"object": "test_helpers.test_clock",
"created": 1680112806,
"deletes_after": 1680717606,
"frozen_time": 1577836800,
"livemode": false,
"name": null,
"status": "ready"
}

Retrieves a test clock.

Parameters

No parameters.

Returns

Returns the TestClock object. Otherwise, this call throws an error.

GET /v1/test_helpers/test_clocks/:id
$stripe = new \Stripe\StripeClient('sk_test_BQokikJ...2HlWgH4olfQ2sk_test_BQokikJOvBiI2HlWgH4olfQ2');
$testClock = $stripe->testHelpers->testClocks->retrieve(
'clock_1Mr3I22eZvKYlo2Ck0rgMqd7',
[]
);
Response
{
"id": "clock_1Mr3I22eZvKYlo2Ck0rgMqd7",
"object": "test_helpers.test_clock",
"created": 1680112806,
"deletes_after": 1680717606,
"frozen_time": 1577836800,
"livemode": false,
"name": null,
"status": "ready"
}

Returns a list of your test clocks.

Parameters

No parameters.

More parameters

  • ending_beforestring

  • limitinteger

  • starting_afterstring

Returns

A associative array with a data property that contains an array of up to limit test clocks, starting after starting_after. Each entry in the array is a separate test clock object. If no more test clocks are available, the resulting array will be empty.

GET /v1/test_helpers/test_clocks
$stripe = new \Stripe\StripeClient('sk_test_BQokikJ...2HlWgH4olfQ2sk_test_BQokikJOvBiI2HlWgH4olfQ2');
$testClocks = $stripe->testHelpers->testClocks->all(['limit' => 3]);
Response
{
"object": "list",
"url": "/v1/test_helpers/test_clocks",
"has_more": false,
"data": [
{
"id": "clock_1Mr3I22eZvKYlo2Ck0rgMqd7",
"object": "test_helpers.test_clock",
"created": 1680112806,
"deletes_after": 1680717606,
"frozen_time": 1577836800,
"livemode": false,
"name": null,
"status": "ready"
}
]
}

Delete a test clock Test helper

Deletes a test clock.

Parameters

No parameters.

Returns

The deleted TestClock object is returned upon success. Otherwise, this call throws an error.

DELETE /v1/test_helpers/test_clocks/:id
$stripe = new \Stripe\StripeClient('sk_test_BQokikJ...2HlWgH4olfQ2sk_test_BQokikJOvBiI2HlWgH4olfQ2');
$deleted = $stripe->testHelpers->testClocks->delete(
'clock_1Mr3I22eZvKYlo2Ck0rgMqd7',
[]
);
Response
{
"id": "clock_1Mr3I22eZvKYlo2Ck0rgMqd7",
"object": "test_helpers.test_clock",
"deleted": true
}

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

Parameters

  • frozen_timetimestampRequired

    The time to advance the test clock. Must be after the test clock’s current frozen time. Cannot be more than two intervals in the future from the shortest subscription in this test clock. If there are no subscriptions in this test clock, it cannot be more than two years in the future.

Returns

A TestClock object with status Advancing is returned upon success. Otherwise, this call throws an error.

POST /v1/test_helpers/test_clocks/:id/advance
$stripe = new \Stripe\StripeClient('sk_test_BQokikJ...2HlWgH4olfQ2sk_test_BQokikJOvBiI2HlWgH4olfQ2');
$testClock = $stripe->testHelpers->testClocks->advance(
'clock_1Mr3I22eZvKYlo2Ck0rgMqd7',
['frozen_time' => 1680199613]
);
Response
{
"id": "clock_1Mr3I22eZvKYlo2Ck0rgMqd7",
"object": "test_helpers.test_clock",
"created": 1680112806,
"deletes_after": 1680717606,
"frozen_time": 1577836800,
"livemode": false,
"name": null,
"status": "advancing"
}