billSDK
Plugins

Time Travel

Test subscription cycles in development

Development only.

Setup

import { timeTravelPlugin } from "@billsdk/time-travel";

billsdk({
  plugins: [timeTravelPlugin()],
});

Add time_travel_state table to your schema.

React Overlay

import { TimeTravelOverlay } from "@billsdk/time-travel/react";

{process.env.NODE_ENV === "development" && (
  <TimeTravelOverlay customerId={user.id} />
)}
PropDefault
baseUrl"/api/billing"
position"bottom-right"
defaultCollapsedtrue

API

EndpointBody
POST /time-travel/advance{ customerId, days?, hours?, months? }
POST /time-travel/set{ customerId, date }
POST /time-travel/reset{ customerId }
POST /time-travel/get{ customerId }
GET /time-travel/list

Test Renewal

// Advance past period end
await fetch("/api/billing/time-travel/set", {
  method: "POST",
  body: JSON.stringify({
    customerId: user.id,
    date: subscription.currentPeriodEnd,
  }),
});

// Process
await billing.api.processRenewals({ customerId: user.id });

On this page