This page contains common issues that developers might encounter when integrating with the Swiftrans API and their solutions.
Problem: Getting authentication errors even with correct credentials.
Solution:
/api/v1/loginBearer {token}// Correct authentication
$loginResponse = login($username, $password);
$token = $loginResponse['data']['access_token'];
// Use token in subsequent requests
$headers = [
'Authorization: Bearer ' . $token,
'Content-Type: application/json'
];
Problem: Access token expires during API calls.
Solution:
Problem: API returns validation errors for JSON requests.
Solution:
application/json// Correct request format
const response = await fetch('https://openapi.swiftrans.id:7654/api/v1/disbursement', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify(data)
});
Problem: Validation errors for missing fields.
Solution:
Problem: Requests timing out or failing to connect.
Solution:
// PHP with retry logic
$maxRetries = 3;
$retryDelay = 1; // seconds
for ($i = 0; $i < $maxRetries; $i++) {
try {
$response = makeApiCall();
break;
} catch (Exception $e) {
if ($i === $maxRetries - 1) {
throw $e;
}
sleep($retryDelay * pow(2, $i));
}
}
Problem: SSL verification failures.
Solution:
Problem: Disbursement fails due to insufficient funds.
Solution:
/api/v1/balance endpoint before disbursement// Check balance before disbursement
const balanceResponse = await fetch('https://openapi.swiftrans.id:7654/api/v1/balance', {
headers: { 'Authorization': `Bearer ${token}` }
});
const balance = await balanceResponse.json();
if (balance.data.balance >= disbursementAmount) {
// Proceed with disbursement
} else {
// Insufficient balance
}
Problem: Bank account validation failures.
Solution:
/api/v1/check-account endpoint to validate before disbursement{
"bank_code": "5",
"account_number": "1234567890"
}
Problem: Reference ID already exists.
Solution:
Problem: Hitting API rate limits.
Solution:
// Rate limiting with delay
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
async function makeApiCallWithRateLimit() {
try {
return await makeApiCall();
} catch (error) {
if (error.status === 429) {
await delay(5000); // Wait 5 seconds
return await makeApiCall();
}
throw error;
}
}
Problem: Response doesn't match expected format.
Solution:
// Robust response handling
try {
const response = await fetch(url, options);
const data = await response.json();
if (!response.ok) {
throw new Error(data.message || 'API request failed');
}
return data;
} catch (error) {
console.error('API Error:', error);
throw error;
}
Problem: Code works in sandbox but fails in production.
Solution:
https://openapi.swiftrans.id:7654Problem: Disbursement remains process for extended periods.
Solution:
Problem: Transactions fail during bank maintenance.
Solution:
If you continue to experience issues: