protected function getErrorCode($response)
    {
        $code = isset($response['details']) ? $response['details'][0]['code'] : null;

        switch ($code) {
            case 'conekta.errors.processing.bank.declined':
            case 'conekta.errors.processing.bank_bindings.declined':
                return new ErrorCode('card_declined');

            case 'conekta.errors.processing.bank.insufficient_funds':
            case 'conekta.errors.processing.bank_bindings.insufficient_funds':
                return new ErrorCode('insufficient_funds');

            case 'conekta.errors.processing.charge.card_payment.suspicious_behaviour':
                return new ErrorCode('suspected_fraud');

            case 'conekta.errors.parameter_validation.expiration_date.expired':
                return new ErrorCode('invalid_expiry_date');

            case 'conekta.errors.parameter_validation.card.number':
                return new ErrorCode('invalid_number');

            case 'conekta.errors.parameter_validation.card.cvc':
                return new ErrorCode('invalid_cvc');
        }

        $code = Arr::get($response, 'type');

        return new ErrorCode($code === 'processing_error' ? $code : 'config_error');
    }