User vs Admin functions
The following operations are found in both provider.user and provider.admin:
getUserisPayingUserrefundsubscription.getsubscription.getAllsubscription.cancelsubscription.reactivate
They do the same thing, yet require differenet parameters.
User functions
Section titled “User functions”The functions from provider.user are using a session token of an authenticated user. NextJS and ExpressJS packages will automaticaly fetch the token from the cookies, so you can call the functions only with function’s specific parameters (instead of passing the token every time).
For example calling the getUser from the user property:
//the token is automaticaly fetched by the package
provider.user.getUser()//the token is automaticaly fetched by the package
req.productflame.user.getUser()provider.user.getUser('<token>'){ method: "GET", url: "https://api.productflame.com/v1/auth/user", headers: { "Authorization": "<apiKey>", "Cookie": "__at__=<token>" } }These functions should be used inside endpoints that handle user specific actions, such as authentication, managing subscriptions, etc.
Admin functions
Section titled “Admin functions”The functions from provider.admin don’t need a token. They only require an email adress or an id, which will be used to trigger the action on the chosen user.
For example calling the getUser from the user property:
provider.admin.getUser('<email|id>')provider.admin.getUser('<email|id>')provider.admin.getUser('<email|id>'){ method: "GET", url: "https://api.productflame.com/v1/admin/user/<email|id>", headers: { "Authorization": "<apiKey>" } }These functions should be used on dashboards or by administrators. They are used internally by ProductFlame’s web dashboard, when you manage your users from there.