Create a full user
Trustap supports two types of users.
- Full Users – Have a Trustap account and can receive payouts (required for sellers).
- Guest Users – Limited functionality, cannot receive payouts.
A seller must become a full user to receive payouts.
Step 1: Request an authorization code from Trustap SSO
Create a button “Register with Trustap” that will redirect the user to Trustap to the following URL.
'Location: https://sso.trustap.com/auth/realms/trustap-stage/protocol/openid-connect/auth'
. '?client_id=' . $CLIENT_ID
. '&redirect_uri=' . $REDIRECT_URI
.'&response_type=code'
. '&scope=openid p2p_tx:offline_create_join p2p_tx:offline_accept_deposit p2p_tx:offline_cancel p2p_tx:offline_confirm_handover’
. '&state=' . $state
For example.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Register with Trustap</title>
</head>
<body>
<h2>Register as a Full User on Trustap</h2>
<button onclick="redirectToTrustap()">Register with Trustap</button>
<script>
function redirectToTrustap() {
// Replace these values with your actual credentials
const clientId = "65697990-9f1c-4e11-8d67-12345160c50a";
const redirectUri = encodeURIComponent("https://mymarkt.com/*");
const state = "random_state_string"; // This should be a random unique string for security
// Define the scopes needed
const scope = encodeURIComponent("openid p2p_tx:offline_create_join p2p_tx:offline_accept_deposit p2p_tx:offline_cancel p2p_tx:offline_confirm_handover");
// Construct the Trustap authentication URL
let realm = "trustap-stage";
if (isProduction) {
realm = "trustap";
}
const trustapAuthUrl = `https://sso.trustap.com/auth/realms/${realm}/protocol/openid-connect/auth?client_id=${clientId}&redirect_uri=${redirectUri}&response_type=code&scope=${scope}&state=${state}`;
// Redirect the user to Trustap
window.location.href = trustapAuthUrl;
}
</script>
</body>
</html>
Step 2: User consents to scopes
The user must give permission (consent) to the partner (client) to perform certain Trustap actions on their behalf. The scopes define what actions can be performed using the API (like creating/joining transactions, accepting transactions, and so on).
Step 3: Register on Trustap
After consenting, the user completes the Trustap account setup.
Step 4: Receive the authorization code on your server
- Once the user registers, Trustap redirects the user to the redirect URI with a
code
parameter. - Your server exchanges this code for access tokens by making a POST request to Trustap:
URL:
https://sso.trustap.com/auth/realms/{realm}/protocol/openid-connect/token
Headers:
Content-Type: application/x-www-form-urlencoded
Parameters:
client_id = {client_id}
client_secret = {client_secret}
grant_type = authorization_code
redirect_uri = {redirect_uri}
response_type = code
scope = openid p2p_tx:offline_create_join p2p_tx:offline_accept_deposit p2p_tx:offline_cancel p2p_tx:offline_confirm_handover p2p_tx:offline_complain p2p_tx:offline_claim
code = {code} (received in the previous step)
Store the Trustap Full User ID in your database. This is retrieved from the
id_token
. The ID token is encoded as a JWT, and that the user ID is stored in theuid
claim.Redirect the seller back to Trustap’s profile completion page:
https://app.stage.trustap.com/profile/payout/personal?edit=true&client_id={CLIENT_ID}