initCardPayment function
Initialisation d'un paiement par carte bancaire (CyberSource Secure Acceptance) : renvoie la réponse de l'API (payment_url, reference, ...).
Implementation
Future<Map<String, dynamic>?> initCardPayment(
Map<String, dynamic> data, String token) async {
final String url = '$baseUrl/api/transactions/public/requesttopay/init';
try {
final response = await http.post(
Uri.parse(url),
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer $token',
},
body: jsonEncode(data),
).timeout(paymentRequestTimeout);
final decoded = jsonDecode(response.body);
if (decoded is Map<String, dynamic>) {
return decoded;
}
return null;
} catch (e) {
return null;
}
}