vercel / nextjs-subscription-payments

Clone, deploy, and fully customize a SaaS subscription application with Next.js.
https://subscription-payments.vercel.app/
MIT License
5.83k stars 1.19k forks source link

Question: Why have a customers table if it is 1:1 with Users & has only 1 column of stripe_customer_id? #231

Closed EarthlingDavey closed 11 months ago

EarthlingDavey commented 11 months ago

Hi, I don't think there is much more to add that isn't in the title.

Question: Why have a customers table if it is 1:1 with Users & has only 1 column of stripe_customer_id?

I am porting this repo to work with a diferent database, I'm curious what are the benefits of having an isolated customer table. When the alternative woud be to have a column of stripe_customer_id in the User table.

Thanks!

EarthlingDavey commented 11 months ago

I understand, it's because customer is a private table, it will never be accessible by the user.

mousindev commented 3 weeks ago

Hi, I was kind of wondering the same. I am exploring this template to help speeding up the setup of the payment and auth part for future projects. One related question that comes to my mind also is why only the mapping of the IDs? First I don't see exactly when it is set. I think it was populated as soon as I signed up despite I did not subscribe to any product at that time. But back to the question, it would be helpful to have also the company name (in B2B scenarios the user that signs up will do it on behalf of the company they work at) to avoid them entering it both in the Stripe Customer Portal and our app. Regarding your comment of 1:1 relationship, in B2B scenarios it would be interesting to be able to add multiple users to one customer (company).