getAllProviders method

dynamic getAllProviders({
  1. dynamic context,
  2. required String transactionId,
  3. required String transactionAmount,
  4. required String transactionCallBackUrl,
  5. required String merchandUserName,
  6. required String merchandPassword,
  7. required String xApiKey,
  8. required String mode,
  9. required Function actionAfterProccess,
})

Implementation

getAllProviders({
  context,
  required String transactionId,
  required String transactionAmount,
  required String transactionCallBackUrl,
  required String merchandUserName,
  required String merchandPassword,
  required String xApiKey,
  required String mode,
  required Function actionAfterProccess,
}) async {
  try {
    var jsonResponse;
    var url = Uri.parse(
        "${constant.baseUrl}/gateway/gateways?t_id=$transactionId&t_sum=$transactionAmount&t_url=$transactionCallBackUrl");
    var response =
        await http.get(url, headers: getGlobalHeader(xApiKey, "$merchandUserName:$merchandPassword", mode));
    jsonResponse = json.decode(response.body);
    if (response.statusCode == 200) {
      print("This is /getAllProviders response : $jsonResponse");
      if (jsonResponse != null) {
        return json.decode(response.body)['data'];
      }
    } else {
      if (jsonResponse != null) {
        print("Response :  : $jsonResponse");
        Navigator.of(context).pop();
        actionAfterProccess(transactionId, "FAILED");
        return [];
      }
    }
  } catch (e) {
    print("Error : $e");
    Navigator.of(context).pop();
    actionAfterProccess(transactionId, "FAILED");
    showInfoDialog(context, "Something went wrong , please try again or later");
  }
}