createCheckout static method

Future createCheckout({
  1. bool test = false,
  2. 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);
  }
}