Skip to main content
Subscriptions are the most common way to charge customers on a recurring basis. A subscription plan has a fixed base price that customers pay at a regular interval (monthly, quarterly, annually), and can include features with usage limits or additional usage-based charges.
Example
A project management tool offers a Pro plan at $20/month that includes 10 seats, 50GB storage, and SSO access.

Setting up

Define a recurring plan in your autumn.config.ts:
autumn.config.ts
import { feature, item, plan } from 'atmn';

export const messages = feature({
  id: 'messages',
  name: 'Messages',
  type: 'metered',
  consumable: true,
});

export const sso = feature({
  id: 'sso',
  name: 'SSO',
  type: 'boolean',
});

export const pro = plan({
  id: 'pro',
  name: 'Pro',
  price: { amount: 20, interval: 'month' },
  items: [
    item({
      featureId: messages.id,
      included: 1000,
      reset: { interval: 'month' },
    }),
    item({
      featureId: sso.id,
    }),
  ],
});
Push changes with atmn push.

Attaching a subscription

Use billing.attach to attach a subscription to a customer. With redirectMode: "always", a checkout URL is always returned for the customer to complete payment or confirm the plan change.
import { useCustomer } from "autumn-js/react";

const { attach } = useCustomer();

await attach({ planId: "pro", redirectMode: "always" });
When a subscription is created, Autumn:
  1. Creates a Stripe subscription with the plan’s prices
  2. Provisions balances for each feature in the plan
  3. Starts the billing cycle based on the plan’s interval

Billing intervals

Plans support the following billing intervals:
IntervalDescription
weekBilled every week
monthBilled every month
quarterBilled every 3 months
semi_annualBilled every 6 months
yearBilled annually
You can create a separate plan for each interval you want to support. For example, if you want to support monthly and annual plans, you can create a pro_monthly plan and a pro_annual plan. You can also configure a custom interval_count to charge at non-standard intervals (e.g., every 2 months).

Managing subscriptions

Once a customer has an active subscription, you can manage upgrades, downgrades, and cancellations. See Managing Subscriptions for details on:
  • Upgrades — prorated charges for switching to a higher-priced plan
  • Downgrades — scheduled at end of billing period
  • Cancellations — immediate or end-of-period

Subscription statuses

StatusDescription
activeSubscription is in good standing
trialingCustomer is in a free trial period
past_duePayment failed, needs attention
scheduledWill activate at end of current billing period (e.g., downgrade)
expiredSubscription has ended