Clone Slack's fair per-seat pricing in a simple way
Lago is an open-source billing API that helps engineers implement faster their billing engines. More and more companies, such as Notion or Slack, are implementing a complex per-seat fair pricing model.
What is a fair per-seat pricing?
You only make your customers pay for active members and what they really use. Members added or removed during a billing period are pro-rated based on the number of days used.
The total number of units to be paid at the end of a period depends on the actual number of days really used by the members.
Lago has developed a special feature to implement faster than ever this fair pricing policy, called persistent billable metrics. Let’s try to replicate Slack’s pricing with Lago!
You can find the main Lago repository here.
Before we get started, you need to:
- Install Docker on your machine;
- Make sure Docker Compose is installed and available (it should be the case if you’ve chosen to install Docker via Docker Desktop);
- Make sure Git is installed on your machine; and
- A cup of tea (or coffee)! ☕️
💡 We use basic CURL API calls for this demo, but Lago also provides API clients in order to make the implementation process easier.
1. Setting up your Lago billing engine
Start running Lago on your own environment. You will have access to the Lago API and Lago UI (frontend admin panel to perform no-code tasks).
You can now open your browser and go to http://localhost to connect to the application. Lago's API is exposed at http://localhost:3000.
If needed, you can override your environment variables (learn more).
2. Creating a persistent billable metric
As our user seats are billed month over month unless you remove a user, we are going to use the persistent billable metrics, with a recurring_count aggregation. This means that you won’t have to send an event each month for a user who was added a few months ago and who’s still using your product. Lago will keep it in your “billing memory” until you remove this user.
It’s useful to emphasize several points here:
- The aggregation property used is the seat_id. Lago counts the number of unique seat_id at the end of each billing period; and
- The recurring_count aggregation type enables the creation of a fair per-seat pricing (we’ll talk about the creation of events later).
3. Creating a price plan with per-seat charges
To replicate Slack’s pricing, we can focus on building the Pro plan, starting at €8.25 per active user if you pay monthly.
Let’s break down the code written above:
- The Pro plan has no base subscription amount. Therefore, amount_cents is set to 0 for the plan;
- The amount_currency is in EUR. But you can use any available currency;
- The charges and the plan are paid in_arrears. This means everything is billed based on the consumption of the period; and
- Only one usage-based charge is created. Each seat is priced €8.25 per full month. Pro-rated charges will be determined by the events sent to Lago.
4. Create a customer and assign the Pro plan
First, let’s create a customer using the API. As Airbnb is a power customer of Slack, we can take this company as an example.
Then, we assign the Pro plan to this Airbnb customer.
About the subscription request:
- The external_id of the subscription is unique (you can choose your own ID); and
- The assigned plan has an anniversary billing time, which means that this Pro plan will be billed on the same day each month, depending on the subscription’s anniversary date (in this case, the 19th of each month).
5. Send events to create pro-rated user seats
Each user seat is priced €8.25 for a full month. Let’s send events to get a better understanding of this logic. Lago allows you to send persistent events:
5.1 User added for full month or persisted from previous billing periods
Use the operation_type called add to add a user seat to Lago’s billing system.
5.2 User added in the middle of the current period
As the user seat is added in the middle of the month, Lago automatically creates a pro-rated charge based on the number of days used.
In this example, one user was added for the full month and the other only for half the month.
5.3 User removed in the middle of the current period
A user who’s removed during a period is also charged with a pro-rated amount based on the number of days used. Use the operation_type set to remove to remove a user seat during a period.
6. The invoice
Let’s take a closer look at the PDF invoice created by Lago: it shows the seat history for the billing period under consideration. This detailed invoice provides the information necessary for your customers to understand the billing method.
This is how Lago can help you implement a per-seat billing system in just a few hours (not months). It’s easy to build but also easy to maintain.
Two hosting options, same benefits
Whether you choose the cloud version or decide to host the solution yourself, you will benefit from our powerful API and user-friendly interface.
The fastest way to set up your metering and billing system.
The optimal solution for teams who want control and flexibility.