Skip to main content
In this example we’ll create the pricing for a premium AI chatbot. We’re going to have:
  • A Free plan that gives users 5 chat messages per month for free
  • A Pro plan that gives users 100 chat messages per month for $20 per month.
1

Create your pricing plans

Create a plan for each pricing tier that your app offers. In our example we’ll create a “Free” and “Pro” plan, and assign them features.
Browse our Examples for guides on setting up credit systems, top ups and other common pricing models.
Run the following command in your root directory:
This will prompt you to login or create an account, and create an autumn.config.ts file. Paste in the code below, or view our config schema to build your own.
autumn.config.ts
Then, push your changes to Autumn’s sandbox environment.
If you already have products created in the dashboard, run atmn pull to pull them into your local config.
2

Installation

Create an Autumn Secret key, and paste it in your .env variables. Then, install the Autumn SDK. If you’re using the CLI, this will be done for you.
.env
3

Create an Autumn customer

When the customer signs up, create an Autumn customer for them. Autumn will automatically enable the Free plan, since you marked it with the auto-enable flag.
Autumn’s customer ID is the same as your internal user or org ID generated from your auth provider. No need to store any extra IDs.
In the Autumn dashboard, you will see your user under the customers page.
4

Stripe Payment Flow

Call attach when the customer wants to purchase the Pro plan. This will return a Stripe payment URL. Once they’ve paid, Autumn will grant access to “100 messages per month” defined in Step 1.
Use Stripe’s test card 4242 4242 4242 4242 to make a purchase in sandbox. You can enter any Expiry and CVV.
This can be used for any plan changes scenario (upgrades, downgrades, one-time topups, renewals, etc).Upgrades will happen immediately, and downgrades will be scheduled for the next billing cycle.
The redirectMode: "always" flag will always return a payment URL.New purchases redirect to Stripe Checkout to enter payment details, and subsequent charges redirect to an Autumn hosted, one-click confirmation page.You can build your own billing confirmation flows by using the previewAttach function.
Next: Track and limit usage Now that the plan is enabled and you’ve handled payments, you can now make sure that customers have the access to the right features and limits based on their plan.

Track and limit usage

Enforce usage limits and feature permissions using Autumn’s check and track functions