Time Machine is a simulation feature which imitates the key characteristics, behaviours and functions of the billing configurations. It is a virtual time travelling tool which facilitates the integration testing process by carrying out subscription renewals, dunning, webhooks etc on a hypothetical time frame.
You can use Time Machine in the test site to verify if the billing rules configured in your site adhere to your expectations before executing them in real time. This feature can be used in both API and UI versions.
View this doc for more details.
Note: In order to use Time Machine via API , you need to first "enable" the Time Travel option which is available under Settings > Configure Chargebee > Time Machine.
{
"destination_time": 1585065021,
"genesis_time": 1585065021,
"name": "delorean",
"object": "time_machine",
"time_travel_status": "succeeded"
}
<cb_client>.TimeMachine
from chargebee import Chargebee cb_client = Chargebee(api_key="{site_api_key}", site="{site}") response = cb_client.TimeMachine.retrieve("delorean") time_machine = response.time_machine
from chargebee import Chargebee cb_client = Chargebee(api_key="{site_api_key}", site="{site}") response = cb_client.TimeMachine.retrieve("delorean") time_machine = response.time_machine
<cb_client>.TimeMachine.retrieve(<time_machine_name>,{<param name> : <value>,<param name> : <value> ...})
Restart the time machine. This will clear the "customer" data like customer details, subscriptions, invoices, transactions. Also a time travel is initiated to travel back to specified genesis time.
Note: This API call is asynchronous. Use method wait_for_time_travel_completion on the returned time_machine resource which will block until the time travel completes.
from chargebee import Chargebee cb_client = Chargebee(api_key="{site_api_key}", site="{site}") response = cb_client.TimeMachine.start_afresh("delorean") time_machine = response.time_machine
from chargebee import Chargebee cb_client = Chargebee(api_key="{site_api_key}", site="{site}") response = cb_client.TimeMachine.start_afresh("delorean") time_machine = response.time_machine
<cb_client>.TimeMachine.start_afresh(<time_machine_name>,{<param name> : <value>,<param name> : <value> ...})
Travel forward in time. This operation is asynchronous.
from chargebee import Chargebee cb_client = Chargebee(api_key="{site_api_key}", site="{site}") response = cb_client.TimeMachine.travel_forward("delorean", cb_client.TimeMachine.TravelForwardParams( destination_time=1586274640 ) ) time_machine = response.time_machine
from chargebee import Chargebee cb_client = Chargebee(api_key="{site_api_key}", site="{site}") response = cb_client.TimeMachine.travel_forward("delorean", cb_client.TimeMachine.TravelForwardParams( destination_time=1586274640 ) ) time_machine = response.time_machine
<cb_client>.TimeMachine.travel_forward(<time_machine_name>,{<param name> : <value>,<param name> : <value> ...})