Stripe subscriptions

Adds plans (each linked to a Stripe price) and subscriptions. A Plans and billing page lets people pick a plan and pay on Stripe's secure checkout. Stripe then tells the app what happened through a signed webhook (checkout completed, invoice paid or failed, subscription changed or cancelled), and only the server marks a subscription active. Manage billing opens Stripe's customer portal to change card, switch plan or cancel. Rules stop anyone marking their own subscription paid. Staff manage plans and see every subscriber.

Stripe subscriptions: the Plans and billing page, added to Ledgerly, on desktopStripe subscriptions: the Plans and billing page, added to Ledgerly, on a phone

What it adds to your app

Tables plan and subscription (two starter plans). BillingPanel component on a Plans and billing page. A Stripe-signed webhook that applies checkout, invoice and subscription events. Server functions: checkout, billing settings and a manual check with Stripe. A staff page for plans and subscribers.

Tables

  • plan name, description, price, currency, interval, stripe_price_id, features, active, …
  • subscription subscriber_id, plan_id, status, sync, stripe_session_id, stripe_subscription_id, stripe_customer_id, current_period_end

Pages

  • /billing Plans and billing (‹subscriber_role›)
  • /subscriptions-admin Subscriptions (@staff)

Components

  • BillingPanel Plans to choose from, the current subscription and Stripe billing settings

Rules on every write

  • subscription A new subscription starts as pending until Stripe confirms it.
  • subscription Only Stripe can change a subscription.

How its workflows run

Each one is a server workflow in your project: it runs on its trigger, with retries, and its runs show in the builder's log.

  1. Start a Stripe Checkout for a plan

    When the app calls it: server function (‹subscriber_role›). Then: Look up plan, then Call api.stripe.com, then Create subscription.

  2. Apply Stripe's subscription events

    When a webhook arrives: webhook stripe-subscription-events. Then: Look up subscription, then Update subscription.

  3. Check a subscription with Stripe (fallback)

    When the app calls it: server function (‹subscriber_role›, @staff). Then: Look up subscription, then Call api.stripe.com, then Update subscription.

  4. Apply what Stripe said about a subscription

    When a row changes: subscription updated, when sync is requested. Then: Update subscription.

  5. Open Stripe's billing settings for a subscriber

    When the app calls it: server function (‹subscriber_role›). Then: Look up subscription, then Call api.stripe.com.

  6. Tell the subscriber their plan is active

    When a row changes: subscription updated, when status is active. Then: Notify.

Set it up

It merges into the contract of an app you already have. Nothing is overwritten: a name you already use is refused until you pass a prefix.

  1. Pick the project

    Use the button above, or ask your coding agent with the Appbricx MCP server connected (quickstart).

  2. Point it at your tables and roles

    Leave out the ones with defaults; a wrong one is refused with the options your app has.

    ParamWhat it isExample
    subscriber_roleThe role whose people buy a plan (their own table is the subscriber). Optional.member
  3. Connect what it calls

    add the STRIPE_SECRET_KEY secret (project settings); add the STRIPE_WEBHOOK_SECRET secret (project settings). A Stripe account with a recurring price for each plan (paste each price id into the plan). A Stripe webhook endpoint at the URL get_contract lists for stripe-subscription-events (Backend, API in the builder), with its signing secret in STRIPE_WEBHOOK_SECRET.

  4. Preview, then apply to dev

    A dry run shows the diff and the check report; applying it changes your dev environment only.

  5. Deploy

    When dev looks right, deploy. Production gets a snapshot first, so you can roll back.

Use it with your coding agent

The agent reads the template, runs a dry run, shows you the diff and applies it.

Prompt
Add the Stripe subscriptions template (slug "stripe-subscriptions") to my Appbricx project. Read it with get_template, run use_template with dry_run first and show me the diff, then apply it. Ask me where it attaches if you can't tell from my contract (subscriber_role: who subscribes).
MCP call
{
  "tool": "use_template",
  "arguments": {
    "slug": "stripe-subscriptions",
    "project_id": "<your project id>",
    "params": {
      "subscriber_role": "member"
    },
    "dry_run": true
  }
}
CLI
appbricx templates use stripe-subscriptions --param subscriber_role=member --dry-run

Works with

The services this template calls. Each page lists every action and what connecting it takes.

Your agent adds it. Appbricx runs it.