sendSTKPushRequest static method

Future sendSTKPushRequest({
  1. bool test = false,
  2. dynamic body,
})

Implementation

static Future sendSTKPushRequest({bool test = false, body}) async {
  String baseUrl = "https://payment.intasend.com";
  if (test) {
    baseUrl = "https://sandbox.intasend.com";
  }
  var url = "$baseUrl/api/v1/send-mpesa-stk-push/";
  var headers = {"Content-Type": "application/json"};
  final resp = await http.post(Uri.parse(url), headers: headers, body: body);
  if (resp.statusCode == 200) {
    return STKPush.fromJson(json.decode(resp.body));
  } else {
    throw Exception(resp.body);
  }
}