W
Wasp2w ago
Tarek

Saas plans/payments associated to Companies instead of users?

I'm building a saas where our clients are companies and not "users". The Account is a company and so the plan/payment is going to be assosiated with the company. I noticed with the Open Saas template the clients are "users" and the plan is associated to them. Is there a simple way to make plans associate to another model? Obviously I can manually change the code but I was wondering if there is another way I'm missing before I go that route
5 Replies
kapa.ai
kapa.ai2w ago
Hi @Tarek. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the knowledge sources provided, I understand you're looking to adapt the OpenSaaS template to associate plans/payments with companies rather than individual users. The OpenSaaS template is indeed structured with individual users as the primary account holders, with subscription status and payment information tied directly to the user model. There isn't a built-in configuration option to simply switch this association to a company model instead. You would need to modify the code to implement this change. One approach would be to create a multi-tenant structure similar to what was shared in one of the discussions about GitHub-like multi-tenant SaaS: GitHub-like multi-tenant schema shows an example of a schema that supports both individual users and organizations, which might be helpful for your use case. For your specific needs, you would likely need to: 1. Create a Company/Organization entity 2. Modify the Stripe integration code to associate payments with the company rather than the user 3. Update the subscription status logic to work with companies The Discord discussions mention that this is more of a standard app/database design question rather than something specific to Wasp itself. As one community member noted: "nothing Wasp specific here I would say, just normal app/db design." If you're looking for guidance on implementing multi-tenancy in Wasp, there was a discussion about this in the Discord community, though it didn't provide specific implementation details beyond suggesting separate databases for clients. You'll need to manually modify the code in the OpenSaaS template, particularly focusing on the Stripe integration parts in files like stripe.ts and updating the data model to reflect your company-centric approach. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Tarek, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Carlos
Carlos2w ago
Mmm yeah I think best way is to split the User model in Prisma into two entities, one for the user and another for the company, and modify the code to use the correct entity in each case (typescript will help a lot, follow the errors)
MEE6
MEE62w ago
Wohooo @Carlos, you just became a Waspeteer level 13!
Carlos
Carlos2w ago
@Vinny (@Wasp) anything i might have forgotten?
Vinny (@Wasp)
Vinny (@Wasp)2w ago
Yeah it sounds like @Tarek wants a one to many relationship between one companiy that has many users. Then the operations on the server will check if the user belongs to a certain company and give them privileges based on whatever company they belong to, for example. A great way to find the right structure for this is chat with cursor or ChatGPT and use a higher end reasoning model like o3 or Gemini 2.5 pro Max and ask it for a few different approaches and to choose the best one.

Did you find this page helpful?