Subscriptions and Payments
Last updated
Last updated
ScaffoldHub has built-in payments for workspaces using Stripe.
Payments are optional, and you can enable them on the modeling tool.
Check the Setup > Payments with Stripe section for instructions on how to set up payments.
In the modeling tool, you can select between three different strategies of subscriptions:
Membership-based - The subscription is valid for a single tenant and user.
User-based - The subscription is valid for a single user across all tenants.
Tenant-based - The subscription is valid for all users of a tenant.
By default, there are three plans: Free, Basic, and Enterprise.
Each workspace starts on the Free plan.
When the User clicks on Subscribe, it opens the Stripe Checkout page.
After payment is successful, the application enables the Plan.
Users can cancel, upgrade, or downgrade a plan.
When users click Manage Subscription, they are redirected to the Stripe Customer Portal.
When users upgrade or downgrade a plan on the customer portal, a webhook is triggered, and the application is updated.
When users cancel a plan, it is not canceled immediately because they paid for the entire period. The plan is marked to cancel at the end period and remains active until then.
Permissions for features must be configured in the code. It has some helper methods to assist you.
The code is under src/security.ts
.
This prevents different users from making charges to other's credit cards.
For Tenant-based subscriptions, when you delete the tenant related to the subscription, the subscription is automatically canceled on Stripe.
Also, for Tenant-based, removing the manager - the user who signed up for the plan - from the tenant also cancels the membership. This is because other users can't manage a subscription from other users, even if the subscription is related to the entire tenant.
For Membership-based subscriptions, when you remove the member from the tenant, the subscription is automatically canceled on Stripe.
If you need to add or remove plans, you need to change those files:
src/env.server.ts
- Add or remove the required environment variables for the plan.
.env
- Add or remove the required environment variables for the plan.
src/features/subscription/subscriptionPaidPlans.ts
- Add or remove the plan from the list.
src/translation/[lang]/[lang].ts
- Add translations for the new plans.