createPaymentIntent method
Implementation
Future<Map<String, dynamic>> createPaymentIntent(
String amount,
String currency,
String secretKey,
) async {
try {
final Map<String, dynamic> body = {
'amount': amount,
'currency': currency,
'payment_method_types[]': 'card',
};
final response = await http.post(
Uri.parse('https://api.stripe.com/v1/payment_intents'),
body: body,
headers: {
'Authorization': 'Bearer $secretKey',
'Content-Type': 'application/x-www-form-urlencoded',
},
);
return jsonDecode(response.body);
} catch (err) {
return {};
}
}