createPaymentIntent method
Implementation
Future<Map<String, dynamic>?> createPaymentIntent(String amount, String currency, String stripeSecret) async {
try {
Map<String, String> requestHeaders = {
'Content-type': 'application/x-www-form-urlencoded',
'Authorization' : "Bearer $stripeSecret",
};
Map<String, dynamic> body= {"amount": amount, "currency" : currency, "payment_method_types[]": "card"};
var url = "https://api.stripe.com/v1/payment_intents";
var response = await http.post(Uri.parse(url), headers: requestHeaders, body: body).timeout(const Duration(seconds: 10));
dprint(url);
dprint('Response status: ${response.statusCode}');
dprint('Response body: ${response.body}');
return json.decode(response.body);
} catch (ex) {
dprint("stripe createPaymentIntent " + ex.toString());
}
return null;
}