# run-subscription-lifecycle-and-dunning

Run subscriptions through trial, active, past-due and canceled with a dunning retry schedule, refusing invalid transitions

- **Space:** billing-and-subscriptions-public (https://github.com/Tech-Realm/space-billing-and-subscriptions-public/tree/main/run-subscription-lifecycle-and-dunning)
- **Level:** L2 (as the registry reports it)
- **Keys it needs (names only):** none
- **Tools:** python3
- **Routes:** stdlib; checks: 2
- **Uses:** new (no recorded use yet)
- **Install:** `logicpacks pack use billing-and-subscriptions-public/run-subscription-lifecycle-and-dunning` or MCP `get_pack billing-and-subscriptions-public/run-subscription-lifecycle-and-dunning`
- **Files:** CHANGELOG.md, code/billing.py, outcome/EVIDENCE.md, outcome/checks.yaml, outcome/fixtures/event.json, outcome/fixtures/plan.json, outcome/fixtures/usage.json, outcome/results.json, pack.yaml, refs/refs.yaml, spec/SPEC.md, spec/source.md

## Purpose (spec/SPEC.md)

Run subscriptions through trial, active, past-due and canceled with a dunning retry schedule, refusing invalid transitions

## Goal
Every subscription is always in exactly one valid state, failed payments are retried on a schedule, and access follows the state.

## Steps
1. States: trialing -> active | past_due; active -> past_due (payment_failed) -> active (payment_succeeded) | canceled (dunning_exhausted).
2. Dunning: retry on days 0, 3, 5, 7 after the first failure, email each time, cancel after the last.
3. Gate features on state (active/trialing = on, past_due = grace, canceled = off).

## Edge cases
- Payment succeeds after cancel: treat as a new subscription or refund.
- Timezones: schedule retries in UTC.

## Don'ts
- Don't delete canceled subscriptions (keep for invoices/audit).



---

Canonical URL: https://logicpacks.io/packs/billing-and-subscriptions-public/run-subscription-lifecycle-and-dunning

Developed by TechRealm (techrealm.online), the software team. Operated by Al Jash Trading (Establishment), Abu Dhabi, since 1994, the legal entity that hosts and is responsible for the service. Economic licence CN-1030597, Abu Dhabi Registration Authority. Address: Office 5, Bani Yas West 4, Bani Yas, Abu Dhabi, UAE. Website: https://aljashtrading.com. Contact: hello@logicpacks.io, security@logicpacks.io, WhatsApp +1 713 632 2262 (https://wa.me/17136322262).

Machine-readable index: [/llms.txt](/llms.txt). Plain facts: [/about.md](/about.md). Safety: [/safety.md](/safety.md).
