corisPayment function

Future<Map<String, dynamic>?> corisPayment(
  1. Map<String, dynamic> data
)

Implementation

Future<Map<String, dynamic>?> corisPayment(Map<String, dynamic> data) async {
  try {
    final response = await http.post(
      Uri.parse(_apiUrl),
      headers: {'Content-Type': 'application/json'},
      body: jsonEncode(data),
    );

    final decoded = jsonDecode(response.body);
    if (decoded is Map<String, dynamic>) {
      final message = decoded['message']?.toString();
      if (message == 'NETWORK_UNAVAILABLE') {
        decoded['message'] =
            'Réseau indisponible. Veuillez réessayer plus tard.';
      }
      return decoded;
    } else {
      return {'message': 'Réponse inattendue du serveur.'};
    }
  } catch (e) {
    return {'message': 'Erreur de connexion. Veuillez vérifier votre réseau.'};
  }
}