FlowFuse / FlowFuse/flowfuse

Add ability to change pricing of teams/instances/devices

Open
#3,413 2 comments 0 reactions 0 assignees View on GitHub
epic
Dominant language
JavaScript
Stars
400
Forks
89
Avg merge
1d 21h
Merged PRs (30d)
146

Description

### Description

We manage pricing by associating each billable 'thing' with its corresponding Stripe Product and Price Ids per Team Tier.

Whenever a team does a billable action, we reference the product/price details from the associate Team Tier. This means all teams in a tier get the same pricing details.

To introduce a pricing change, we need to agree on how it should get applied with regard existing vs new teams and what changes are needed to support that.

On the Stripe side of things, we create a new Price Object for each Product - we cannot change the $-price of an existing Price object. That will give us a new `price_id`.

If we updated the Team Tier billing details with the new `price_id`, the change would only apply the next time a Team creates/deletes a billable object (instance or device) - as that's the only time we update their subscription to match their true usage. If a team didn't make any billable changes, their subscription would remain untouched on the old price.

Whilst I need to verify this precise behaviour, the basic point is: our existing model was not required to support different teams having different pricing - so any changes in pricing will get applied to all teams in a tier as soon as that team does a billable action.

It has been proposed that any pricing change should only apply to new teams from the point in time the change is applied.

To achieve this we would need to start storing the billing information against the team itself. The Team Tier would store the 'current' product/price ids (and the $-amount we show the user), and when a Team is created, they get copied into the Team. We would then be able to modify the Team Tier's product/prices and they would only apply to new teams.

As a future iteration, I can see we would need the ability to administratively update a Team's billing info to migrate them to the new pricing at some point. Whether that is provided on a per-team basis, or some bulk-update tools/db queries, is up for discussion once we have the core requirement settled.

If this direction is agreed, the tasks are roughly:

```[tasklist]
### Tasks
- [ ] Validate existing behaviour when a price_id is changed for a product
- [ ] Add place in db to store billing info against individual teams
- [ ] Create db migration to copy billing info from TeamTier into Teams for existing teams
- [ ] On Team Create, copy over billing info into Team
- [ ] Update billing logic to pull billing info from Team, not Team Tier
- [ ] Update UI to use pricing info of the Team, not Team Tier when presenting `$` amounts
```

### Which customers would this be available to

None

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.