fetchFees function
Utilitaire pour récupérer les frais via l'API Feexpay
amount : montant de la transaction (String ou int)
reseau : nom du réseau (ex: "MTN CI")
shop : identifiant du shop
Retourne un Map avec les clés: fees, real_amount, iffees
Implementation
Future<Map<String, dynamic>?> fetchFees({
required String amount,
required String reseau,
required String shop,
}) async {
const String url = 'https://api.feexpay.me/api/transactions/details';
try {
final response = await http.post(
Uri.parse(url),
headers: {'Content-Type': 'application/json'},
body: jsonEncode({
'amount': amount,
'reseau': reseau,
'shop': shop,
}),
);
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
return data is Map<String, dynamic> ? data : null;
} else {
return null;
}
} catch (e) {
return null;
}
}