Supported provider codes
| Provider code | Description |
|---|---|
| mtn_ug | MTN Mobile Money Uganda. |
| airtel_ug | Airtel Money Uganda. |
| tricsoftpay_card_ug | TricsoftPay card collections. |
Authenticate once, then use the configured client for collections, disbursements, refunds, and other API requests.
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.
| Provider code | Description |
|---|---|
| mtn_ug | MTN Mobile Money Uganda. |
| airtel_ug | Airtel Money Uganda. |
| tricsoftpay_card_ug | TricsoftPay card collections. |
Business accounts authenticate with an API key ID and API secret. Configure this client once and reuse it for all TricsoftPay requests.
const paymentGateway = axios.create({
baseURL: "{{base_url}}",
timeout: 30000,
headers: {
Authorization: `ApiKey ${api_key_id}:${api_secret}`,
"Content-Type": "application/json",
Accept: "application/json",
},
});type apiKeyTransport struct {
apiKeyID string
apiSecret string
base http.RoundTripper
}
func (t apiKeyTransport) RoundTrip(req *http.Request) (*http.Response, error) {
cloned := req.Clone(req.Context())
cloned.Header.Set("Authorization", "ApiKey "+t.apiKeyID+":"+t.apiSecret)
cloned.Header.Set("Content-Type", "application/json")
cloned.Header.Set("Accept", "application/json")
return t.base.RoundTrip(cloned)
}
baseURL := "{{base_url}}"
paymentGateway := &http.Client{
Timeout: 30 * time.Second,
Transport: apiKeyTransport{
apiKeyID: apiKeyID,
apiSecret: apiSecret,
base: http.DefaultTransport,
},
}use reqwest::{header, Client};
use std::time::Duration;
let base_url = "{{base_url}}";
let mut headers = header::HeaderMap::new();
headers.insert(
header::AUTHORIZATION,
format!("ApiKey {}:{}", api_key_id, api_secret).parse()?,
);
headers.insert(header::CONTENT_TYPE, "application/json".parse()?);
headers.insert(header::ACCEPT, "application/json".parse()?);
let payment_gateway = Client::builder()
.default_headers(headers)
.timeout(Duration::from_secs(30))
.build()?;import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.time.Duration;
String apiKeyAuthorization = "ApiKey " + apiKeyId + ":" + apiSecret;
HttpClient paymentGateway = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(30))
.build();
HttpRequest.Builder requestBuilder(String url) {
return HttpRequest.newBuilder(URI.create(url))
.timeout(Duration.ofSeconds(30))
.header("Authorization", apiKeyAuthorization)
.header("Content-Type", "application/json")
.header("Accept", "application/json");
}using System.Net.Http.Headers;
var paymentGateway = new HttpClient
{
BaseAddress = new Uri("{{base_url}}"),
Timeout = TimeSpan.FromSeconds(30),
};
paymentGateway.DefaultRequestHeaders.TryAddWithoutValidation(
"Authorization",
$"ApiKey {apiKeyId}:{apiSecret}"
);
paymentGateway.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json")
);Personal accounts exchange the API token generated in the dashboard for an access token. Send a POST request to {{base_url}}/auth/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;payload, _ := json.Marshal(map[string]string{
"api_token": "your_api_token_here",
})
req, _ := http.NewRequest(
http.MethodPost,
"{{base_url}}/auth/token/",
bytes.NewReader(payload),
)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)let response = reqwest::Client::new()
.post("{{base_url}}/auth/token/")
.json(&serde_json::json!({
"api_token": "your_api_token_here"
}))
.send()
.await?
.error_for_status()?;String body = """
{"api_token":"your_api_token_here"}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{base_url}}/auth/token/"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());using System.Net.Http.Json;
var response = await new HttpClient().PostAsJsonAsync(
"{{base_url}}/auth/token/",
new { api_token = "your_api_token_here" }
);
response.EnsureSuccessStatusCode();
var token = await response.Content.ReadFromJsonAsync<TokenResponse>();{
"refresh": "eyJ0eXAiOiJKV1...",
"access": "eyJ0eXAiOiJKV1...",
"user": {
"id": 1,
"username": "john",
"user_type": "individual",
"api_access_enabled": true
}
}Use the returned access value as a Bearer token for every authenticated request made by a personal account.
const paymentGateway = axios.create({
baseURL: "{{base_url}}",
timeout: 30000,
headers: {
Authorization: `Bearer ${access}`,
"Content-Type": "application/json",
Accept: "application/json",
},
});req, _ := http.NewRequest(http.MethodGet, "{{base_url}}/example/", nil)
req.Header.Set("Authorization", "Bearer "+accessToken)
req.Header.Set("Accept", "application/json")
resp, err := http.DefaultClient.Do(req)let payment_gateway = reqwest::Client::new();
let response = payment_gateway
.get("{{base_url}}/example/")
.bearer_auth(&access_token)
.send()
.await?;HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{base_url}}/example/"))
.header("Authorization", "Bearer " + accessToken)
.header("Accept", "application/json")
.GET()
.build();using System.Net.Http.Headers;
var paymentGateway = new HttpClient
{
BaseAddress = new Uri("{{base_url}}"),
Timeout = TimeSpan.FromSeconds(30),
};
paymentGateway.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", accessToken);When the access token expires, exchange the refresh token at {{base_url}}/auth/token/refresh/ for a new token pair.
const response = await axios.post(
"{{base_url}}/auth/token/refresh/",
{ refresh: refreshToken },
{ headers: { "Content-Type": "application/json" } },
);
const { access, refresh } = response.data;payload, _ := json.Marshal(map[string]string{
"refresh": refreshToken,
})
req, _ := http.NewRequest(
http.MethodPost,
"{{base_url}}/auth/token/refresh/",
bytes.NewReader(payload),
)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)let response = reqwest::Client::new()
.post("{{base_url}}/auth/token/refresh/")
.json(&serde_json::json!({ "refresh": refresh_token }))
.send()
.await?
.error_for_status()?;String body = "{"refresh":"" + refreshToken + ""}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{base_url}}/auth/token/refresh/"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());var response = await new HttpClient().PostAsJsonAsync(
"{{base_url}}/auth/token/refresh/",
new { refresh = refreshToken }
);
response.EnsureSuccessStatusCode();
var tokens = await response.Content.ReadFromJsonAsync<TokenPair>();{
"access": "eyJ0eXAiOiJKV1...",
"refresh": "eyJ0eXAiOiJKV1..."
}