Integrations

Environment Setup

Authenticate once, then use the configured client for collections, disbursements, refunds, and other API requests.

Overview

Use the sandbox base URL while developing and switch to the production base URL when your integration is approved. In every example, replace {{base_url}} with the complete environment URL including /api.

Authenticate your requests

Supported provider codes

Provider codeDescription
mtn_ug MTN Mobile Money Uganda.
airtel_ug Airtel Money Uganda.
tricsoftpay_card_ug TricsoftPay card collections.

Business accounts with API keys

Business accounts authenticate with an API key ID and API secret. Configure this client once and reuse it for all TricsoftPay requests.

API key client
const paymentGateway = axios.create({
  baseURL: "{{base_url}}",
  timeout: 30000,
  headers: {
    Authorization: `ApiKey ${api_key_id}:${api_secret}`,
    "Content-Type": "application/json",
    Accept: "application/json",
  },
});

Personal account access tokens

Personal accounts exchange the API token generated in the dashboard for an access token. Send a POST request to {{base_url}}/auth/token/.

Create an access token
const response = await axios.post(
  "{{base_url}}/auth/token/",
  { api_token: "your_api_token_here" },
  { headers: { "Content-Type": "application/json" } },
);

const { access, refresh, user } = response.data;

Access token response

{
  "refresh": "eyJ0eXAiOiJKV1...",
  "access": "eyJ0eXAiOiJKV1...",
  "user": {
    "id": 1,
    "username": "john",
    "user_type": "individual",
    "api_access_enabled": true
  }
}

Use the bearer token

Use the returned access value as a Bearer token for every authenticated request made by a personal account.

Bearer-authenticated client
const paymentGateway = axios.create({
  baseURL: "{{base_url}}",
  timeout: 30000,
  headers: {
    Authorization: `Bearer ${access}`,
    "Content-Type": "application/json",
    Accept: "application/json",
  },
});

Refresh an access token

When the access token expires, exchange the refresh token at {{base_url}}/auth/token/refresh/ for a new token pair.

Refresh request
const response = await axios.post(
  "{{base_url}}/auth/token/refresh/",
  { refresh: refreshToken },
  { headers: { "Content-Type": "application/json" } },
);

const { access, refresh } = response.data;

Refresh token response

{
  "access": "eyJ0eXAiOiJKV1...",
  "refresh": "eyJ0eXAiOiJKV1..."
}