Skip to main content

Subscription / Recurring Billing

A subscription lifecycle on a cron clock. active emits invoice_due on its billing schedule (default the 1st of each month); a payment_failed event moves it to past_due, payment_ok restores it, and grace_expired suspends it. Drop-in for SaaS plans, metered billing, and memberships. (Edit the cron for your billing cadence.)

CategoryFoundations
Template IDsubscription-billing
Definitionsubscription_billing v1.0
States3 (initial: active; terminal: suspended)
Transitions4
Operators composedKO42
Audit clockon · tick rate 1

What it's for

  • SaaS plan billing
  • Metered / usage subscriptions
  • Membership lifecycle

States

StateRole
activeinitial
past_dueintermediate
suspendedterminal

Transitions

FromToOperatorFires whenProofTrigger / actions
activeactiveKO42norecurring · cron 0 0 1 * * (UTC) · post: emit invoice_due
activepast_dueKO42noon_event · payment_failed · post: emit subscription_past_due
past_dueactiveKO42noon_event · payment_ok · post: emit subscription_resumed
past_duesuspendedKO42noon_event · grace_expired · post: emit subscription_suspended

Operators it composes

Each transition fires a registry operator through the master equation (compute → prove → verify). This template composes:

  • KO42

Browse the operators at /operators/; the building blocks a transition calls are the framework's protocols. KO42 is the always-on substrate operator; physics operators carry proof_required: true, so each fire runs the full compute → prove → verify path and lands a verifiable proof digest on your entangled state.

Deploy it

Inspect the full definition, then deploy it onto your state machine. Every fire is Zeqond-stamped onto your entangled state.

# 1. Inspect — the full definition (states, transitions, operators) as served
curl -sS https://zeqsdk.com/api/contracts/templates/subscription-billing

# 2. Deploy onto your machine (auth: session; body carries your machine slug)
curl -sS -X POST https://zeqsdk.com/api/contracts/templates/subscription-billing/deploy \
-H "Content-Type: application/json" \
-b "<your session cookie>" \
-d '{"slug":"<your-machine>"}'
# → 201 { "ok": true, "contract": { "id": "…", "currentState": "active", … },
# "template_id": "subscription-billing" }

The deploy path runs the same two-stage validation as the canonical create route (ContractDefinitionSchema.parse + validateContractDefinition against the live registry), writes the creation row onto your entangled state, and schedules the first fire. From there, drive transitions with POST /api/chain/<your-machine>/contracts/<id>/transition or let any triggers fire them autonomously.

Next

  • Contract IDE — author, preview, and deploy contracts (this template is in the Templates tab).
  • State Contracts — the full contract model: conditions, triggers, pre/post actions, lifecycle.
  • Templates Library — every ready-to-deploy contract, grouped by category.
  • Protocols — the named building blocks a transition composes.