There are three susbscription tables:
- Subscriptions - Contains the metadata about a subscription
- School Subscriptions - Joins the school and a subscription
- User Subscriptions - Joins a specific user to a subscription
https://www.lucidchart.com/invitations/accept/64e36df6-dd25-4085-b5af-047228db9e23
A user can have a subscription in two ways. The first is that it is simply their own subscription, e.g. a trial, or a purchase of teacher premium. The second way is by getting it through their school. In both cases, the user has their own user subscription, but in the latter, it joins them with a subscription that is also joined with a school.
When a school subscription is created, there is an after commit callback that checks each of the schools users to determine whether they should be upgraded. This check occurs in #updated_school
in models/concerns/teacher.rb
. In short, if a teacher already has their own subscription, and then joins a school, or their school upgrades to premium, the teacher keeps the subscription with the more distant expiration date. If a teacher changes schools and had a subscription from their old school, they lose it no matter what.
A subscription can be created from:
- A user starting a trial (only if they've never had a subscription.)
- A user purchasing an individual Teacher Premium account through Stripe.
- A user purchasing an individual Teacher Premium account through PO, in which case someone from the sales team upgrades them through the CMS dashboard.
- A school purchasing a School Premium account through Stripe, in which case all teachers in the school are upgraded (if they pass the upgrade check as mentioned in Users Subscriptions Through School Section).
- A school purchases a School Premium Account through PO, and the sales team upgrades the school through the CMS, which in term upgrades all teachers.