Autumn with TypeScript
Implement pricing & billing with React and Node.js
Create your Autumn account and let’s create a the pricing for a premium AI chatbot.
We’re going to charge users $20 per month for 10 messages.
1. Create the product
Create a product in the Products tab.
2. Install autumn-js
3. Integrate Autumn
There are 3 main functions you need to integrate Autumn into your application.
When the customer clicks the “Upgrade to Pro” button, we call attach()
to
redirect them to a Stripe checkout page.
When the customer wants to use a chatbot message, we call check()
to check
if they have remaining messages and are allowed to send one.
track()
to send a usage event to Autumn.You can use your Publishable Key when making attach
and check
requests from the frontend. Attach will return a checkout_url
that you can redirect the customer to.
To handle product upgrades and downgrades however, you’ll need to use a Secret Key from the backend, by opening a backend endpoint and passing the attach
result to the frontend.
Make sure you’ve pasted in your Stripe test secret
key sk_test_...
in the Autumn
dashboard.
Autumn will automatically create a customer if the customer ID is new.