-
Notifications
You must be signed in to change notification settings - Fork 0
Subscriptions
Subscriptions are handled via Stripe.
While seeding the application, three plans must be created both in the database and on Stripe:
- Free
- Growth
- Business
A Plan maps to a Stripe plan.
An Organization maps to a Stripe customer.
An Organization::Card corresponds to the latest customer's Stripe source, which is a Stripe card.
A Subscription maps to a Stripe subscription. A Subscription is associated to a single Bot, allowing each bot to be billed separately, and to be on different plans.
An Invoice maps to a Stripe invoice.
-
A user creates an account and an
Organizationvia theRegistrationsController -
A Stripe customer is created for the
Organization -
A
Botis created for theOrganization3.1 With a free plan
- If the
planparam isfree, then the plan is fetched and associated with the bot'sSubscriptionright away. Failing to provide aplan_idwill fallback to thefreeplan.
3.2 With a paying plan
- If a
planother thanfreeis passed in the params, the user is redirected to thecards#newcontroller action - The user is prompted to enter a credit card, which will be associated to his
Organization. ASubscriptionwill be created with the givenplanandbotpassed in the params.
- If the
When a subscription is created Stripe will:
- Create an invoice
- Pay the invoice
- Close the invoice
When a subscription is automatically renewed Stripe will:
- Create an invoice
- Leave the invoice open for an hour
- Pay the invoice
- Close the invoice
During that hour window we add additional charges to the open invoice. Recurring costs are charged upfront and usage based fees are added to the next month's charges.
Users registered with a free account are able to add a credit card to their Organization. That could be useful when they plan to switch to a paying subscription.
Users starting an account with a paying plan will see the card as already set, and can choose to update it later.
When a user on a free plan changes for a paying plan, he can select the new plan and will be asked to enter a credit card if his Organization doesn't already have one.
When a user on a paying plan changes for another paying plan, the subscription is simply updated with the new plan.
These are the Stripe events the application listens to.
Update Organization with Stripe attributes
Update Organization with Stripe attributes
Update Organization::Card with Stripe attributes
Update Organization::Card with Stripe attributes
Nullify Organization::Card
Update Subscription with Stripe attributes
Update Subscription with Stripe attributes
Update Subscription with Stripe attributes
Create Invoice with Stripe attributes. If the invoice's subscription plan requires additional charges, Stripe Invoice Items are added accordingly.
Update Invoice with Stripe attributes
Update Invoice with Stripe attributes