Get the custom error message from translator.

@param  string $customKey
@return string
343129
protected function getCustomMessageFromTranslator( $customKey )
	{
		if ( ( $message = $this->translator->trans( $customKey ) ) !== $customKey )
		{
			return $message;
		}

		$shortKey = preg_replace( '/^validation\.custom\./', '', $customKey );

		$customMessages = Arr::dot( (array) $this->translator->trans( 'validation.custom' ) );

		foreach ( $customMessages as $key => $message )
		{
			if ( Str::contains( $key, ['*'] ) && Str::is( $key, $shortKey ) )
			{
				return $message;
			}
		}

		return $customKey;
	}
296605
protected function translateErrorMessage($errorCode)
    {
        $message = self::UNKNOWN_ERROR_MESSAGE;

        if (isset(self::$errorMessages[$errorCode])) {
            $message = self::$errorMessages[$errorCode];
        }

        return $message;
    }
596692
public function getActionError($key = null) {
        $errors = $this->getAttribute(ACTION_ERRORS_KEY);

        if ($key === null) {                            // return the first one
            if ($errors) {
                foreach ($errors as $error) return $error;
            }
        }
        elseif (key_exists($key, $errors)) {            // return the specified one
            return $errors[$key];
        }
        return null;
    }
477331
public function translate($key)
    {
        $normalizeKey = $this->normalize($key);

        if ($this->exists($normalizeKey, false)) {
            $string = $this->strings[$normalizeKey];

            // In debug mode, we notice user this is a translated string.
            if ($this->debug) {
                $string = '**' . $string . '**';
            }

            // Store used keys
            if (!in_array($normalizeKey, $this->used)) {
                $this->used[] = $normalizeKey;
            }

            return $string;
        }

        // In debug mode, we notice user this is a translating string but not found.
        if ($this->debug) {
            $this->orphans[$normalizeKey] = $this->backtrace($normalizeKey, $this->traceLevelOffset + 2);

            $key = '??' . $key . '??';
        }

        return $key;
    }
376485
public function getErrorMessage() {
        if($this->errorMessage) {
            return $this->errorMessage;
        }

        return sprintf(self::$defaultErrorMessagePattern, $this->getName());
    }
975611
public function getCustomMethodKey($customName = false)
    {
        if (!$customName) {
            $customName = debug_backtrace()[1]['function'];
        }

        $string = $this->getString() . $this->xmlFilePath . $customName;

        return md5($string);
    }
894387
public function getCustomValue($key)
    {
        if (!array_key_exists($key, $this->customValues)) {
            throw InvalidPayloadException::notExistingCustomValue($key);
        }

        return $this->customValues[$key];
    }
58568
protected function getTranslationsForKeyFromService($selfEdit, $msgInstanceName, $key)
    {
        $translationService = new InstanceProxy($msgInstanceName, $selfEdit);

        return $translationService->getTranslationsForKey($key);
    }
459514
@Override
	protected Object customKey(Object key) {
		if (null != key && key instanceof CharSequence) {
			key = key.toString().toLowerCase();
		}
		return key;
	}
155539
public function translate($key)
    {
        // inproper param given
        if (!is_string($key) && !is_int($key)) {
            throw new \InvalidArgumentException("Invalid argument provided, string required!");

        // value provided not found in dictionary -> return it with slug
        // converted to a space
        } elseif (!array_key_exists($key, $this->dictionary)) {
            return preg_replace('/\\' . $this->config->value('slug_separator') . '/', ' ', $key);

        } else {

            // return with the translated value
            return $this->dictionary[$key];
        }
    }
1350750
protected function getGeneralErrorMessage(\Exception $caught)
    {
        $singleName = $this->getEntityNameSingular();
        $message = "There was an error when saving {$singleName} data: %s";
        return sprintf($this->translate($message), $caught->getMessage());
    }
445256
@Override
	protected Object customKey(Object key) {
		if (null != key && key instanceof CharSequence) {
			key = StrUtil.toCamelCase(key.toString());
		}
		return key;
	}
207332
protected function getCustomMessageFromTranslator($key)
    {
        if (($message = $this->translator->trans($key)) !== $key) {
            return $message;
        }

        // If an exact match was not found for the key, we will collapse all of these
        // messages and loop through them and try to find a wildcard match for the
        // given key. Otherwise, we will simply return the key's value back out.
        $shortKey = preg_replace(
            '/^validation\.custom\./', '', $key
        );

        return $this->getWildcardCustomMessages(Arr::dot(
            (array) $this->translator->trans('validation.custom')
        ), $shortKey, $key);
    }
1263103
protected function getPreparedKey($key)
    {
        $preparedKey = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $key));
        $template = "add_paydata[KEY]";
        return str_replace('KEY', $preparedKey, $template);
    }
730745
protected static function translate($key)
    {
        if (is_callable(static::getTranslatorFunction())) {
            $translated = call_user_func(static::getTranslatorFunction(), $key);
            if ($key !== $translated) {
                return $translated;
            } else {
                return '';
            }
        } else {
            return '';
        }
    }
1188416
public static function getErrorDescription($errorCode)
    {
        switch (intval($errorCode)) {
            default:
            case self::ERROR:
                return 'Undefined error.';
            case self::SYSTEM_ERROR:
                return 'A general system error occurred.';
            case self::MAINTENANCE_ERROR:
                return 'System is undergoing maintenance, request could not be handled.';
            case self::AUTHENTICATION_ERROR:
                return 'Login failed. Check your API credentials.';
            case self::CONFIGURATION_ERROR:
                return 'Config error occurred, e.g. terminal not configured properly. Check terminal settings.';
            case self::COMMUNICATION_ERROR:
                return 'Communication with issuer failed, please contact support.';
            case self::CONNECTION_ERROR:
                return 'Connection to issuer could not be established, please contact support.';
            case self::ACCOUNT_ERROR:
                return 'Issuer account data invalid, please contact support.';
            case self::TIMEOUT_ERROR:
                return 'Issuer does not respond within given time-frame - please reconcile.';
            case self::RESPONSE_ERROR:
                return 'Issuer returned invalid response - please reconcile and contact support.';
            case self::PARSING_ERROR:
                return 'Issuer response could not be parsed - please reconcile and contact support.';
            case self::INPUT_DATA_ERROR:
                return 'Invalid were data sent to the API.';
            case self::INVALID_TRANSACTION_TYPE_ERROR:
                return 'Invalid transaction type was passed to API.';
            case self::INPUT_DATA_MISSING_ERROR:
                return 'Required argument is missing.';
            case self::INPUT_DATA_FORMAT_ERROR:
                return 'Argument passed in invalid format.';
            case self::MASTERCARD_FORMAT_ERROR:
                return 'This is a format error stopped by MasterCard due to invalid formatting in certain fields.';
            case self::INPUT_DATA_INVALID_ERROR:
                return 'Argument passed in valid format but makes no sense (e.g. incorrect country code or currency).';
            case self::INVALID_XML_ERROR:
                return 'The input Builder could not be parsed due to invalid code.';
            case self::INVALID_CONTENT_TYPE_ERROR:
                return 'Missing or invalid content type: should be text/xml!';
            case self::WORKFLOW_ERROR:
                return 'A transaction was triggered that is not possible at this time in the workflow,' .
                       'e.g. a refund on a declined transaction.';
            case self::REFERENCE_NOT_FOUND_ERROR:
                return 'Reference transaction was not found.';
            case self::REFERENCE_WORKFLOW_ERROR:
                return 'Wrong Workflow specified.';
            case self::REFERENCE_INVALIDATED_ERROR:
                return 'Reference transaction already invalidated!';
            case self::REFERENCE_MISMATCH_ERROR:
                return 'Data mismatch with reference, e.g. amount exceeds reference.';
            case self::DOUBLE_TRANSACTION_ERROR:
                return 'Transaction doublet was detected, transaction was blocked.';
            case self::TRANSACTION_NOT_FOUND_ERROR:
                return 'The referenced transaction could not be found.';
            case self::CHARGEBACK_NOT_FOUND_ERROR:
                return 'Chargeback not found!';
            case self::RETRIEVAL_REQUEST_NOT_FOUND_ERROR:
                return 'Retrieval Request not found!';
            case self::FRAUD_REPORT_NOT_FOUND_ERROR:
                return 'Fraud Report not found!';
            case self::PROCESSING_ERROR:
                return 'Transaction declined by issuer.';
            case self::INVALID_CARD_ERROR:
                return 'Transaction declined, Credit card number is invalid.';
            case self::ISSUER_OCT_NOT_ENABLED_ERROR:
                return 'OCT not enabled error.';
            case self::EXPIRED_CARD_ERROR:
                return 'Transaction declined, expiration date not in the future or date invalid.';
            case self::TRANSACTION_PENDING_ERROR:
                return 'Transaction pending.';
            case self::CREDIT_EXCEEDED_ERROR:
                return 'Amount exceeds credit card limit.';
            case self::ISSUING_ERROR:
                return 'The voucher could not be issued!';
            case self::RISK_ERROR:
                return 'Transaction declined by risk management.';
            case self::INTERCHANGE_REJECT_ERROR:
                return 'Interchange reject received for transaction!';
            case self::FRONT_END_REJECT_ERROR:
                return 'Transaction declined by frontend reject!';
            case self::BIN_COUNTRY_CHECK_ERROR:
                return 'Card bin does not match billing country.';
            case self::CARD_BLACKLIST_ERROR:
                return 'Card is blacklisted.';
            case self::BIN_BLACKLIST_ERROR:
                return 'BIN blacklisted.';
            case self::COUNTRY_BLACKLIST_ERROR:
                return 'Country blacklisted.';
            case self::IP_BLACKLIST_ERROR:
                return 'IP address blacklisted.';
            case self::BLACKLIST_ERROR:
                return 'Value from the Transaction Request or Risk Parameters is blacklisted.';
            case self::CARD_WHITELIST_ERROR:
                return 'PAN Whitelist Filter blocked the transaction.';
            case self::CARD_LIMIT_EXCEEDED_ERROR:
                return 'Card limit exceeded configured limits.';
            case self::TERMINAL_LIMIT_EXCEEDED_ERROR:
                return 'Terminal limits exceeded.';
            case self::CONTRACT_LIMIT_EXCEEDED_ERROR:
                return 'MID limits exceeded.';
            case self::CARD_VELOCITY_EXCEEDED_ERROR:
                return 'Velocity by unknown card exceeded!';
            case self::CARD_TICKET_SIZE_EXCEEDED_ERROR:
                return 'Ticket size by unknown card exceeded!';
            case self::USER_LIMIT_EXCEEDED_ERROR:
                return 'User limit exceeded configured limits.';
            case self::MULTIPLE_FAILURE_DETECTION_ERROR:
                return 'Found user transaction declined by issuer.';
            case self::CS_DETECTION_ERROR:
                return 'CrossSelling Error!';
            case self::RECURRING_LIMIT_EXCEEDED_ERROR:
                return 'Amount/count by recurring subscription exceeded.';
            case self::IRIS_FILTER_DECLINED_ERROR:
                return 'Transaction declined by risk management.';
            case self::IRIS_FILTER_ON_HOLD_ERROR:
                return 'Transaction on hold, a manual review will be done';
            case self::AVS_ERROR:
                return 'Address Verification failed.';
            case self::MAX_MIND_RISK_ERROR:
                return 'MaxMind High Risk Error.';
            case self::THREAT_METRIX_RISK_ERROR:
                return 'ThreatMetrix High Risk Error.';
            case self::IP_NOT_WHITELISTED_ERROR:
                return 'Transaction declined by risk management, IP is NOT whitelisted!';
            case self::DOMAIN_BLACKLISTED_ERROR:
                return 'Transaction declined by risk management, domain is blacklisted!';
            case self::FRAUD_ERROR:
                return 'Please contact the risk team!';
            case self::IBAN_BLACKLIST_ERROR:
                return 'Transaction declined by risk management, iban blacklisted!';
            case self::REMOTE_ERROR:
                return 'Some error occurred on the issuer.';
            case self::REMOTE_SYSTEM_ERROR:
                return 'Some error occurred on the issuer.';
            case self::REMOTE_CONFIGURATION_ERROR:
                return 'Issuer configuration error.';
            case self::REMOTE_DATA_ERROR:
                return 'Some passed data caused an error on the issuer.';
            case self::REMOTE_WORKFLOW_ERROR:
                return 'Remote workflow error.';
            case self::REMOTE_TIMEOUT_ERROR:
                return 'Issuer has time-out with clearing network.';
            case self::REMOTE_CONNECTION_ERROR:
                return 'Issuer could not reach clearing network.';
        }
    }
553860
public function normalizeKey($key)
	{
		// Built-in/custom filter, normalized to lowercase
		if (preg_match('/^#[a-z_0-9]+$/Di', $key))
		{
			return strtolower($key);
		}

		// Valid callback
		if (is_string($key) && is_callable($key))
		{
			return $key;
		}

		throw new InvalidArgumentException("Invalid filter name '" . $key . "'");
	}