createTransaction static method

Future<Map<String, String?>> createTransaction(
  1. String mainUrl,
  2. String token,
  3. dynamic data
)

Implementation

static Future<Map<String, String?>> createTransaction(
    String mainUrl, String token, var data) async {
  http.Response? responseData = await WebClient.postPaymentData(
      mainUrl, _createTransactionEndpoint, token,
      data: data);
  if (responseData != null) {
    if (responseData.statusCode == 200) {
      return {
        "responseCode": SwitchpayWeb.success.toString(),
        "response": responseData.body
      };
    } else if (responseData.statusCode == 404) {
      return {
        "responseCode": SwitchpayWeb.transactionError.toString(),
        "response": responseData.body
      };
    } else {
      return {
        "responseCode": SwitchpayWeb.error.toString(),
      };
    }
  } else {
    return {
      "responseCode": SwitchpayWeb.timeout.toString(),
    };
  }
}