Stripe Billing allows businesses to manage customer relationships with recurring payments, usage triggers, and other customizable features.  These ar

Test clocks: How we made it easier to test Stripe Billing integrations

submited by
Style Pass
2024-05-09 22:30:03

Stripe Billing allows businesses to manage customer relationships with recurring payments, usage triggers, and other customizable features. 

These are key processes for any business, and for that reason businesses need to validate that their Stripe Billing integrations behave as they expect. But integrations are often error prone due to common misconceptions about time: days always have 24 hours (not when we change the clocks twice a year), February always has 28 days (true, except for leap years), timestamps will always be in the same format (yyyy-mm-dd hh:mm:ss is the default, but it’s not universal), system clocks are always set to the right time, and so on.

Billing integrations are also difficult to test. Historically, the only way to run a test was to wait for time to pass—typically by creating test configurations with shorter subscription cycles than real production systems, or running 10-second trials to force subscriptions to cycle—and then look for any bugs that might surface in the course of normal business. Of course, doing anything that is not a perfect mirror of your production system is a shaky foundation to build on.

We sought to address these challenges with the launch of test clocks, which allow users to simulate the passage of time in Billing scenarios without waiting for actual seconds to tick by in the real world. A test clock, when associated with Customer objects, allows users to associate a time reference with each Customer and its associated Billing resources. When the test clock runs, the Subscription and Invoice objects will behave as if time has actually passed, changing states and triggering webhooks. With a test clock, users can—for example—perform the leap-year test with just a few API calls or clicks in the Dashboard.

Leave a Comment