# Stripe SaaS Subscription Lifecycle: Trials, Grace, Retention

> Everything after Stripe Checkout for a small SaaS: card-less trials, grace periods, export window, data retention, promo codes, webhooks, admin console and jobs, with a policy simulator that catches timeline mistakes.

Stripe SaaS Subscription Lifecycle: Trials, Grace, Retention is a paid AI agent skill on Agensi by Nate Freed, in E-commerce. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $9 (one-time purchase)
- Creator: [Nate Freed](https://www.agensi.io/creators/nate-freed)
- Category: [E-commerce](https://www.agensi.io/skills/ecommerce)
- Version: 1.0
- Last updated: 2026-11-28
- Security: scan passed (2026-11-28); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/stripe-saas-subscription-lifecycle-trials-grace-retention
- Tags: apis-backend, ecommerce, data-databases

## About this skill

Most Stripe skills stop at Checkout. This one implements everything after it for a small SaaS on Node/Express and Postgres: a free trial without a card plus a reminder email, monthly, yearly and lifetime plans, four promo-code types (free lifetime, percent off, fixed amount off, free months) with usage limits and an atomic free-lifetime redemption, and signature-verified, idempotent webhooks that drive one explicit state machine. Failed payments get a grace period that never slides with Stripe's retries. When access ends, users keep an export window, data is retained for a period you choose, a warning goes out before deletion, and resubscribing within retention gives them back their data. Includes Customer Portal wiring, an access-check middleware, an audited admin console API (separate key, re-entry for sensitive actions) and idempotent scheduled jobs. Before any code, a Python simulator walks your policy day by day and flags mistakes such as a deletion warning that lands after the data is gone or a grace period longer than retention. Ships Prisma and SQL schemas, TypeScript templates written for Prisma, an email checklist and a test plan using Stripe test mode and test clocks. The agent works in Stripe test mode only and asks before every outward-facing step; going live is a checklist you run yourself.

## Requires

- Node 18+ with Express and TypeScript
- PostgreSQL 13+, Prisma recommended
- Stripe account in test mode
- npm packages: stripe, zod
- Python 3.8+ for the simulator
- prisma
- Node.js
- tsx
- Optional: Stripe CLI for local webhook testing
- Optional: An email sender or SMTP account
- Optional: tsx to run setupPrices.ts
- Optional: supertest for handler tests

## Known limitations

Stripe only, Node/Express with Postgres. The TypeScript templates are written for Prisma; on a plain-SQL project the agent ports their queries to your SQL client using schema.sql. No metered or per-seat billing, Connect, or tax setup. The admin console is an API; you build the UI in your own frontend. The shared admin key suits one or two operators, not a team. Email is queued in an outbox; sending is up to your email provider or an SMTP sender you already have. Data purge needs your own per-table purgeUserData implementation and stays report-only until enabled. Templates were type-checked and run against in-memory fakes and a local Postgres, not against a live Stripe account; re-run the test plan in your own Stripe test mode, especially after SDK upgrades.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Stripe SaaS Subscription Lifecycle: Trials, Grace, Retention skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### Will this touch my live Stripe account?

No. The agent works with test-mode keys only. The app's Stripe client refuses a live key unless you set STRIPE_ALLOW_LIVE=true in production, setupPrices.ts refuses live keys entirely, and going live is a checklist you run yourself.

### I use plain SQL, not Prisma. Does it still work?

schema.sql gives you every table and constraint, idempotent, for Postgres 13+. The TypeScript templates are written for Prisma, so the agent ports their queries to your SQL client and keeps the same transaction boundaries.

### Does it send emails?

No. Eleven lifecycle emails are rendered as plain text and queued in an email_outbox table with dedupe keys. You choose the sender, and real sending waits for your approval.

### Can it delete my users' data by mistake?

Deletion stays report-only until you implement purgeUserData for your tables and set LIFECYCLE_ENABLE_DELETION=true after reading a dry-run report. It also never deletes anyone without a deletion warning sent at least a day earlier.

### Why is the free trial handled in the app instead of in Stripe?

A card-less trial has no payment method, so the app's own clock and access check run it. If the user subscribes with more than 48 hours of trial left, Checkout carries the remaining trial over.

### What does the simulator need?

Python 3.8+ and nothing else: standard library only, no network, deterministic output. Run it in CI on your policy.json.

### Does it work on serverless hosts?

Yes. Instead of the in-process hourly scheduler, call runLifecycleJobs from a scheduled function or a protected endpoint. Access stays correct between runs because it is computed from timestamps.

### Is there an admin UI?

The admin console is an API (users, grants, revokes, promo codes, policy, prices, analytics, activity log) with a separate key and an audit trail. You build the screens in your own frontend.

### Has it been tested against Stripe?

The templates were type-checked under strict TypeScript and run against in-memory fakes and a local Postgres, not a live Stripe account. The included test plan walks you through Stripe test mode and test clocks before you go live.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
