Step 2: Backend Integration
Mercoa has a fully documented Rest API that can be used in any language. We also have Node, Python, and Java SDKs.
One of our goals at Mercoa is to provide a seamless and whitelabeled experience for your users. As part of the experience, Mercoa does not force users to create a new account or login to a different system.
Instead, Mercoa uses JWT tokens that you generate to transparently authenticate the user session on the frontend.
Steps to generate a token:
- User logs into your platform
- Find the Mercoa Entity that corresponds to that user’s business.
- Optional: Sync individual users and their roles. This is required for Approvals.
- Generate a JWT and pass it to the frontend.
- Use the JWT with our frontend SDK, React Components, or embedded iFrame.
If you do not plan on using the frontend components, check out our payments only guide
Creating a Token
Let’s create an endpoint that authenticates the user, generates a JWT with the entityId
, and return the generated token. We will use Mercoa’s Generate JWT Token endpoint to do the heavy lifting for us.
Using the Token
Now that we have a token, we can use it to authenticate the user in our frontend application. Tokens have a default expiration of 24 hours, but you can change this by passing in the expiresIn
option when generating the token.