Guide

Testing billing over time: test clocks and what to check

The expensive billing bugs live in the weeks after a payment fails: the third reminder, the suspension, the cancellation. A test clock is how you see them before a customer does.

5 min read · Last checked

Key points

  • Test the timeline, not only the happy path. Time-based behaviour is where billing logic breaks.
  • Write the expected result before you advance the clock: which email, which webhook, which state.
  • Know what your clock does not move, and cover it another way.
  • Test mode only. A clock cannot be used with live payments.

What to test

  • The first, second and last reminder, and the wording a customer sees.
  • What your product does during the grace period and after suspension.
  • Whether your webhook receiver handles the suspend and cancel events, and ignores a repeat.
  • What happens when the customer pays after being suspended.

How a TenaBill clock works

A clock belongs to your merchant and has a frozen time that only moves forward. Customers you attach to it are evaluated at the clock’s time and are skipped by the normal wall-clock sweep. Advancing the clock moves time, then runs the same reminder and grace-period suspend and auto-cancel sweeps the worker runs, for that clock’s customers only. Deleting the clock returns them to the wall clock.

A recipe

Create a clock and a test customer, and attach the customer. Create an invoice due 30 days from the clock’s time. Set the dunning configuration to a grace period of 7 days and auto-cancel after 14. Advance 35 days and expect the first reminder. Advance another 10 days to see the suspension, then another 15 days to see auto-cancel. Delete the clock when you are done.

What it does not move yet

Renewal invoices, trial expiry and proration are created by the payment provider, not by TenaBill’s jobs, so they do not move with a TenaBill clock. Stripe offers its own test clocks for simulating subscriptions, trials and plan changes over time in a sandbox, so use those for the provider side.

Limits to plan around

  • One advance can move at most 400 days, and a clock can be at most 800 days from the real date.
  • A merchant can have 25 clocks, and a clock can hold 3 customers.
  • A customer that already has a provider-linked subscription cannot be attached.
  • The calls use console sign-in with the Edit permission, not a merchant API key.

What to know before you rely on this

  • Every create, attach and advance is refused with test_clocks_unavailable_in_live_mode when payments run live.
  • Time only moves forward. To repeat a scenario, create a new clock.

Questions people ask

Will it send real emails?

Advancing runs the same reminder sweeps as the worker, so give test customers an address you control.

Can I test a renewal with it?

Not yet. Renewal, trial expiry and proration follow the payment provider, so use the provider’s test clocks for those.

Sources

Keep reading

Try it with test cards