CulqiError.fromJson constructor

CulqiError.fromJson(
  1. Map<String, dynamic> response,
  2. int errorCode
)

Implementation

CulqiError.fromJson(Map<String, dynamic> response, int errorCode){

  String errorType = response['type'];

  if(_errorsOnServer.containsKey(errorType)){
    if(_errorsOnServer[errorType] == CulqiErrorType.ParameterError){
      String errorSubType = response['code'];

      if(_errorsFromParameter.containsKey(errorSubType)) _errorType = _errorsFromParameter[errorSubType];
      else _errorType = CulqiErrorType.ParameterError;

    }else{
      _errorType = CulqiErrorType.ServerValidationFailed;
    }
  }else{
    _errorType = CulqiErrorType.ServerValidationFailed;
  }

  _errorMessage = response['merchant_message'];
  _errorCode = errorCode;
}