I am building an app utilizing the MERN stack (MongoDB, Express.js, React/Redux, Node.js) where there will be three user account types: Client, Company, Admin.
Client account can search and partner with Company accounts where they can submit orders.
Company account will be a paid subscription (via Stripe) where they can complete orders submitted by client accounts.
Admin will be an interface to view all users, orders, etc..
I am trying to determine the best approach for create multiple user account types in Mongo. I assume there will need to be two different registration forms. I'd like a single login form that will determine if an account is client or company and display relevant information based on their role.
Looking for input on the best/most scalable approach for this.
Related
I want to build a project where a user will be able to press on a button to authorize my platform to access their data (e.g shopify data). When my platform has access (to their shopify platform) it will send that data to my database.
My questions is:
In order for my rest api to access the data (from e.g shopify platform) i have to give the rest api the api key of the user which is simple if it a single account, but when i have multiple users using the same rest api how should i handle it? How can i give the rest api the access code so it can pull the data (from e.g their shopify platform) for each user? What is the name of the technology that needs to be considered here?
I am a built lost on the terminology of my question which has given me a bit of a headache when trying to google it.
First off, you create an App that Shopify approves, and then your merchant customers would install this App in their store. That approval process by both Shopify and the merchant means you are given permission to access their Shopify data.
Next, you create some value by allowing the merchant to see their data in ways unique to what it is you are doing. So far, your database contains nothing but the name of the store and the access token with permission to access the Shopify API.
How you then proceed in your own App is up to you. Not much else to it really, if you already know what your value add is. Code that part up and you're done!
Currently, I working with Stripe gateway service. In my integration use only one Dashboard Stripe Account (one Publishable key + Secret key). I intend that my system create charges in two diferrentes Dashboard Stripe Account, depending others conditions.
I have analysed the "Connected accounts" using only one Dashboard Stripe Account, but is not usefull for me. I intend that each billing company have their Dashboard Stripe Account access (without mistake).
Is there any alternative beyond create customers / payment methods in both Dashboard Stripe Accounts?
pic1:
pic2:
You can build your application to manage two separate sets of keys based on the business logic for when to use one account or the other, but outside of Connect there is no other native support for something like this from Stripe. But you can absolutely do it manually. Yes, you would need to create any customers in both accounts, but this is true in a platform-connected account arrangement, too.
I've been working on a NodeJs web application that uses APi's and a number of differently branded Front-end's for different sellers. Sellers can list their product by visiting appropriate Front-End. However I've hit a problem where there is no logic preventing sellers accessing other seller accounts.
There are several API's that interact with the product, so an idea was to filter all API's against the seller ID to prevent the wrong seller accessing the wrong product. i.e When Seller A lists a product, an sellerID is recorded against product. So if Seller B tries to access the UpdateProducts API against Seller A product, their Login ID will not match the saved sellerID and it will be denied. I think this will work but checking access against products sounds taxing. Are there any better way to do this ?
Before accessing any data from database every request should be checked if it has token authorization. If token is valid, it is possible to get userId from token and search any data for the given userId.
P.S. This approach I'm using in REST API
Using Node.js
I got a question with the flow of the API.
My web app allows users to use the site for free but gives them a choice to "subscribe" to other users and view their premium content which charges them monthly.
Looking at the stripe API, to add a subscription to a user, I would need customer object. Would the proper flow of this be:
User signs up and in the backend, create a stripe customer for said user and save the id into my user object database.
When user subscribes to another user, grab their customer id from the database and create the subscription.
Also side question, does this allow for multiple subscriptions of the same product? Because a user can subscribe to multiple users
Thanks!
Your understanding of Customers sounds correct; you collect a user's credit card details, create a Customer object, then using that id, sign the Customer up for a Subscription.
With a Stripe Subscription you can use quantity or have multiple subscription items attached to a single Subscription. So if the user already has an active subscription, you could grab this and increase the quantity or add a second plan.
e.g. you could bill a user for Plan A and Plan B on a single Subscription, or 2 x Plan A, etc
see:
https://stripe.com/docs/api/subscription_items/create#create_subscription_item-quantity
https://stripe.com/docs/api/subscription_items/create
We're planning a web service based on recurring monthly payments.
The site would have similar user accounts as Netflix or Spotify. The site would have an account section were the user can manage the billing and other details.
I've looked into different payment gateway provides, but I'm still wondering how to implement the user account as a part of the main site and how to combine that to the billing system.
First some information:
The site would first have just one monthly plan xx$/month
Credit cards need to be accepted
We're based in EU
We don't want to use PayPal
The user account section would contain:
User profile (name, email, etc.)
Website options (features on / off)
Subscription & billing management (edit credit card, current period, cancel, etc)
Questions:
How to combine the basic user accounts on my site with the billing system provider?
What information should I store in my own database?
Should I use a 3rd party user account management software on top of a payment gateway provider?
If so, which one would work similar to Spotify's account management?
How to setup the first sign up flow where user enters CC information?
Thank you for the ideas!
This is relatively easy to do using Laravel (a php framework) and a package called cashier. This package uses a payment service called Stripe which allows you to create recurring payments. There is even a tutorial on how to do it on Laracast.