Authenticate your session
To authenticate your access to the Payroc gateway, include a session token every time you run the Hosted Fields script on a webpage.
Before you begin
- Make sure you have your API key for both the test environment and the production environment.
- Make sure that your integration can handle errors. If a request is unsuccessful, we return an error that follows the RFC 7807 format. For more information about errors, go to Errors.
Integration steps
Step 1. Generate a Bearer token.
Step 2. Generate a session token from the Bearer token.
Step 1. Generate a Bearer token
To authenticate your integration, you need to use a Bearer token. To generate a Bearer token, send your API key in a request to our Identity Service.
Note: You need to generate a new Bearer token before the previous Bearer token expires.
Request
To generate a Bearer token, Include your API key in a x-api-key header in a POST request to our Identity endpoint.
Example request
Response
If your request is successful, we return a response that contains your Bearer token, information about its scope, and when it expires.
Example response
If your request is successful, we return a response that contains your Bearer token, information about its scope, and when it expires.
Step 2. Generate a session token from the Bearer token
You must generate a new session token each time you initialize Hosted Fields. A session token expires after 10 minutes.
When you generate a session token, you need to specify the version of the Hosted Fields JavaScript library that you are using. Include the version number in the libVersion parameter in the body of your request.
Request
To generate a session token, send a POST request to our Processing Terminals endpoint.
Include the following headers in your request:
- Content-Type: Include application/json as the value for this parameter.
- Authorization: Include your Bearer token in this parameter.
- Idempotency-Key: Include a UUID v4 to make the request idempotent.
To create the body of your request, use the following parameters:
Request
Example request
Response fields
If your request is successful, our gateway generates a session token. The response contains the following fields: