curl --request GET \
--url https://api.example.com/api/v1/payments/wallet/balance{
"wallet_balance": {
"balance": "<string>",
"currency": "<string>"
}
}Get the current Africa’s Talking wallet balance
curl --request GET \
--url https://api.example.com/api/v1/payments/wallet/balance{
"wallet_balance": {
"balance": "<string>",
"currency": "<string>"
}
}curl http://localhost:8000/api/v1/payments/wallet/balance
{
"wallet_balance": {
"balance": "KES 5,432.10",
"currency": "KES"
}
}
{
"detail": "Failed to get wallet balance"
}
200 - Balance retrieved successfully500 - Failed to query wallet balancePre-Payment Validation
Financial Monitoring
Low Balance Alerts
Reconciliation
payments.py:230-241
AT_USERNAME - Your Africa’s Talking usernameAT_API_KEY - Your Africa’s Talking API keyimport requests
def check_balance():
response = requests.get('http://localhost:8000/api/v1/payments/wallet/balance')
data = response.json()
# Parse balance (remove currency prefix and commas)
balance_str = data['wallet_balance']['balance']
amount = float(balance_str.split()[-1].replace(',', ''))
# Alert if low
if amount < 1000:
print(f"⚠️ Low balance: {balance_str}")
# Send alert notification
return amount
# Check balance before large payment
balance = check_balance()
if balance >= payment_amount:
# Proceed with payment
pass
async function getWalletBalance() {
const response = await fetch('http://localhost:8000/api/v1/payments/wallet/balance');
const data = await response.json();
console.log('Current balance:', data.wallet_balance.balance);
return data.wallet_balance;
}
// Monitor balance
getWalletBalance().then(balance => {
console.log(`Wallet: ${balance.balance} ${balance.currency}`);
});
Always returns 0 or test balance
Failed to get wallet balance error
AT_API_KEY is set correctlyBalance doesn't match dashboard