createCheckout static method
Future
createCheckout(
{ - bool test = false,
- dynamic body,
})
Implementation
static Future createCheckout({bool test = false, body}) async {
String baseUrl = "https://payment.intasend.com";
if (test) {
baseUrl = "https://sandbox.intasend.com";
}
var url = "$baseUrl/api/v1/checkout/";
var headers = {"Content-Type": "application/json"};
final resp = await http.post(Uri.parse(url),
headers: headers, body: jsonEncode(body));
if (resp.statusCode == 200 || resp.statusCode == 201) {
Checkout checkout = Checkout.fromJson(json.decode(resp.body));
return checkout;
} else {
throw Exception(resp.body);
}
}